內(nèi)容很詳細(xì),涉及到虛線邊框圓角問題及解決過程。
2.ios截圖
①截某個顯示圖片的控件上的截圖
UIGraphicsBeginImageContext(_imgView.frame.size);
[_imgView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
UIGraphicsEndImageContext();
return viewImage;
這里只能截取_imgView上顯示的圖片及imgView上面覆蓋的子視圖,而不能截取imgView某個子視圖內(nèi)imgView的圖片。
②截取某個控件上某一部分的截圖
拖動、縮放、裁剪框UI效果,沒有邊界判斷,裁剪范圍不是裁剪框的區(qū)域demo
http://www.itdecent.cn/p/a76b8385facc
解決裁剪出的圖片不是裁剪框范圍的問題
https://blog.csdn.net/maggiezzzzz/article/details/51741816
3.ios使用系統(tǒng)插件之后,默認(rèn)按鈕上的文字是英文的,類似navigationItem.rightBarButtonItem、UIImagePickerController拍照和裁剪頁面選定了風(fēng)格之后,顯示的文字或圖片都是默認(rèn)的,想要全部顯示中文,除了通過代碼依次改變之外,還可以通過設(shè)置info.plist文件中Localization native development region為China
4.關(guān)于UITextfield
①修改textfield占位符字體顏色
參考后最簡單的方法:
[phoneTf setValue:[UIColor whiteColor] forKeyPath:@"placeholderLabel.textColor"];
②textfield設(shè)置文字與左邊框距離
//設(shè)置左邊視圖的寬度
textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 8, 0)];
//設(shè)置顯示模式為永遠(yuǎn)顯示(默認(rèn)不顯示 必須設(shè)置 否則沒有效果)
textField.leftViewMode = UITextFieldViewModeAlways;
5.關(guān)于UILabel
① 完成中間六個數(shù)字樣式

首先設(shè)置字體大小textSize,根據(jù)字體大小算出字體間距textWidth,設(shè)置字間距NSKernAttributeName,但是第一個字與邊距是沒有距離的,所以再次設(shè)置段落樣式首行字符縮進距離firstLineHeadIndent,居中設(shè)置沒有任何意義,最后把樣式賦值給label。
CGSize textSize = [@"3" boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:48]} context:nil].size;
CGFloat textWidth = textSize.width;
NSString *labelText = [NSString stringWithFormat:@"%s",szTotpHash];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText attributes:@{NSKernAttributeName:@(_textSpace)}];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
paragraphStyle.firstLineHeadIndent = _textSpace;
paragraphStyle.alignment = TextAlignmentCenter;
self.dPassword.attributedText = attributedString;
6.圖層疊加與攔截事件
兩個疊加的圖層A、B,A在B圖層下方:
① 若點擊時希望A響應(yīng),則B設(shè)置userInteractionEnabled為NO,A設(shè)置為YES。
② 若希望點擊時B響應(yīng),則A、B都要設(shè)置userInteractionEnabled為YES
③系統(tǒng)默認(rèn)不能跟用戶交互的UI:UIImageView,UILabel
默認(rèn)和用戶交互的:UIView,UIScrollView,UItableView等
7.設(shè)置父視圖透明度 不影響子視圖
preView.backgroundColor=[[UIColor blackColor]colorWithAlphaComponent:0.5];
8.宏定義生成隨機色
#define ZRRandomColor ZRColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
9.tabbar 去線條,加陰影
//移除頂部線條
self.tabBar.backgroundImage = [UIImage new];
self.tabBar.shadowImage = [UIImage new];
//添加陰影
self.tabBar.layer.shadowColor = [UIColor lightGrayColor].CGColor;
self.tabBar.layer.shadowOffset = CGSizeMake(0, -5);
self.tabBar.layer.shadowOpacity = 0.3;