新建nylcopylabel
繼承自uilabel
, 然後新增長按手勢, 把text賦值給貼上板, 當長按的label時候, label的背景顯示高亮狀態, 當複製按鈕消失, 高亮取消. (利用uimenucontrollerwillhidemenunotification
的通知監聽複製按鈕消失)
nylcopylabel
*label =
[nylcopylabel
new];[
self
.view addsubview:label]
;
//
// nylcopylabel.m
// gooddoctorfordoctor
//// created by nyl on 2019/7/17.
//#import
"nylcopylabel.h"
@inte***ce nylcopylabel()
@property (nonatomic, strong)
uipasteboard
*pasteboard;
@end
@implementation nylcopylabel
-(instancetype)initwithframe:
(cgrect
)frame
return
self;}
-(void)addlongpressges
-(void)actionlongpregressges:
(uilongpressgesturerecognizer
*)ges }-
(bool
)canbecomefirstresponder -(
bool
)canperformaction:
(sel
)action withsender:
(id)sender
returnno;
}-(void)copy:
(id)sender
-(void)menuhidemenunotification
-(void)dealloc
@end
//
// nylcopylabel.h
// gooddoctorfordoctor
//// created by nyl on 2019/7/17.
//#import
<
uikit
/uikit
.h>
ns_assume_nonnull_begin
@inte***ce nylcopylabel
:uilabel
@end
ns_assume_nonnull_end
移動端 ios 長按複製相容方案
移動端頁面,需要複製一段文字碼。在ios中,長按文字區域,預設選中的範圍,超出了我長按的文字區域,把上面的和下面的另乙個div的文字也給我包含進來了,並不是我想要的!舉個例子 如下圖 1.我長按的區域是紅色方框內的區域,想要複製框裡的文字內容。2.結果卻是下圖,即便 ios 上能再稍微操作一下 變成...
iOS 文字滾動的Label
在我們開發的過程中會遇到文字的長度大於label的寬度的情況,有三種處理方式 1 顯示不下的內容用 來代替 缺點 沒法顯示全內容 2 採取折行的方式 缺點 高度沒法確定,會影響其他內容的顯示 3 讓文字在label中滾動顯示,這種方式既節省了空間,又可以讓使用者看到所有的內容 其中方式3又可以有兩種...
QT 使用自己的可以點選的label
我這裡,繼承qlabel class lb public qlabel lb lb lb lb const qstring text,qwidget parent 0 qlabel parent 好像這裡給parent傳東西,我看文件說如果parent 0就是彈出來那種視窗,不是0就是嵌入的視窗 還...