收起键盘的三种方法
1.重载UIViewController的touchesBegin方法,在里面执行[self.view endEditing:YES];
2.直接执行[[UIApplication shareApplication] setAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];用于在获取当前UIViewController比较困难时。
3,直接执行[[[UIApplication shareApplication] keyWindow] endEditing:YES];
设置应用内的系统控件语言
如:1.在UIWebView中长按会弹出系统的上下文菜单。 2.在UIImagePickerController中使用系统的照相机界面。 3.在编辑状态下的UITableViewCell,处于待删除状态时,会有一个删除按钮。
解决办法 打开info.plist文件 增加如下内容
截屏功能
系统API -(UIView *)sanpshotViewAfterScreenUpdates:(BOOL)afterUpdates;
忽略编译警告
对没问题的源文件, 我们加上-w编译参数即可。
我们也可以用-Wno-unused-variable只禁掉未使用变量的警告
Xcode技巧
快捷键
清除DerivedData
~/Library/Developer/Xcode/DerivedData
图片拉伸
[[UIImage imageNamed:@""] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
[[UIImage imageNamed:@""] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
图片渲染的问题
UIImage*image=[UIImageimageNamed:@""];
image=[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
隐藏导航条的返回标题
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
给button设置边框颜色和圆角
button.layer.cornerRadius = 2;
button.layer.masksToBounds = YES;
//button边框颜色设置
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGColorRef color = CGColorCreate(colorSpaceRef, (CGFloat[]){255/255.0, 0/255.0, 0/255.0,1});
[button.layer setBorderWidth:1];
[button.layer setBorderColor:color];
[button setTitle:@"你好" forState:UIControlStateNormal];
毛玻璃效果
UIImageView * imageview = [[UIImageView alloc] init];
imageview.image = [UIImage imageNamed:@"mgkj_QS_20160111112029952.jpg"];
imageview.userInteractionEnabled = YES;
imageview.contentMode = UIViewContentModeScaleAspectFit;
imageview.frame = CGRectMake(0, 64, SCREEN_WIDTH,SCREEN_HEIGHT);
[self.view addSubview:imageview];
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
effectview.frame = CGRectMake(0, 0, imageview.frame.size.width, SCREEN_HEIGHT);
effectview.alpha = 0.93;
[imageview addSubview:effectview];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(10, 50, 100, 40);
[button setBackgroundColor:[UIColor whiteColor]];
[button setTitle:@"sdfg" forState:UIControlStateNormal];
[effectview.contentView addSubview:button];
图片绕自身旋转
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[_loadingView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];