1. 粘貼板
UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
pastboard.string = @"123";
========================================
2. 配合調(diào)試輸出
iOS底層是GCC,所以也支持 __func__標(biāo)識符械拍,用于打印當(dāng)前函數(shù)名傍妒,配合__line__悯嗓,可以說是排錯利器。
3. button 取消高亮 和? 文字圖片居中()
Button.adjustsImageWhenHighlighted = NO;
(1)首先設(shè)置圖片顯示類型骚秦,避免拉伸
Button.imageView.contentMode = UIViewContentModeScaleAspectFit;
(2)如果是 左圖片 右文字(button默認(rèn)顯示)她倘,只改變上下距離即可
Button.imageEdgeInsets = UIEdgeInsetsMake(10,0, 10,0);
(3)如果是 左文字? 右圖片,根據(jù)button子視圖 imageView 和 titleLabel計算
[Button setTitleEdgeInsets:UIEdgeInsetsMake(0, -Button.imageView.image.size.width, 0, Button.imageView.image.size.width)];
[Button setImageEdgeInsets:UIEdgeInsetsMake(10, Button.titleLabel.bounds.size.width, 10, -self.Button.titleLabel.bounds.size.width)];
(4) 文字在上 圖片在下
?[button setTitleEdgeInsets:UIEdgeInsetsMake(button.imageView.size.height + 20 ,-button.imageView.frame.size.width, 0.0,0.0)];//文字距離上邊框的距離增加imageView的高度骤竹,距離左邊框減少imageView的寬度帝牡,距離下邊框和右邊框距離不變
[button setImageEdgeInsets:UIEdgeInsetsMake(-20, 0,0.0, -button.titleLabel.bounds.size.width)];//圖片距離右邊框距離減少圖片的寬度,其它不變