美文网首页
开发小技巧

开发小技巧

作者: 温暖的男人 | 来源:发表于2016-07-20 14:14 被阅读21次

收起键盘的三种方法

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

相关文章

  • 使用Storyboards开发的10个小技巧

    使用Storyboards开发的10个小技巧 使用Storyboards开发的10个小技巧

  • iOS开发小技巧:根据文本,字体,计算UILabel高度及宽度

    iOS开发小技巧:根据文本,字体,计算UILabel高度及宽度 iOS开发小技巧:根据文本,字体,计算UILabe...

  • 2--NSTimer

    大纲: 创建计时器 暂停 恢复 销毁 开发小技巧 一、创建计时器 二、暂停 三、恢复 四、销毁 五、开发小技巧

  • 开发小技巧

    表格中刷新指定分区,UITableViewRowAnimationFade淡入淡出动画,[str integerV...

  • 开发小技巧

    *- 捡起初心, 慢慢走,希望自己好好努力,志于不用工作的人 * 1、禁止第三方键盘 在要填密码的地方, 为了安全...

  • 开发小技巧

    1、页面上的图片可以有两中形式: img和给 设置背景图background-img,一般需要占位的图片使用img...

  • 开发小技巧

    收起键盘的三种方法 1.重载UIViewController的touchesBegin方法,在里面执行[self....

  • iOS开发小技巧之--WeakSelf宏的进化

    iOS开发小技巧之--WeakSelf宏的进化

  • 小程序开发小技巧

    如何去掉button的边框? wxml wxss 参数传值的方法 data-id 我们可以给HTML元素添加dat...

  • IOS开发小技巧

    1、让Xcode显示编译时间,关闭Xcode,然后在终端输入命令 2、如何浏览苹果开源网站 从苹果源码首页下看到O...

网友评论

      本文标题:开发小技巧

      本文链接:https://www.haomeiwen.com/subject/zerhdttx.html