开发小技巧

收起键盘的三种方法

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"];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,161评论 5 13
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥ios动画全貌。在这里你可以看...
    每天刷两次牙阅读 8,613评论 6 30
  • 1,Search Bar 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现cl...
    小小东阅读 1,118评论 2 10
  • //设置尺寸为屏幕尺寸的时候self.window = [[UIWindow alloc] initWithFra...
    LuckTime阅读 855评论 0 0
  • 1、Category(类别) 什么是Category 1、Category可以在不获悉不改变原代码的情况下向已有的...
    阿道奇阅读 355评论 0 1