iOS xcode 汇总

全局变量
extern

边缘和范围
UIEdgeInsets 相当于CGRect, 只不过四个参数分别代表四个边缘
UIEdgeInsetsMake(t,l,b,r) 创建边缘, 可以为负
UIEdgeInsetsInsetRect(rect, edge) 内切边缘, 内切值为负则向外扩展
CGRectGetWidth(rect) 获取宽度

自动布局
autoresizingMask
UIViewAutoresizingFlexibleWidth 自动调整view的宽度,保证左边距和右边距不变
UIViewAutoresizingFlexibleHeight 自动调整view的高度,以保证上边距和下边距不变

交互
UIControlEventTouchUpInside 在按下范围内抬起响应
UILongPressGestureRecognizer 长按手势
UIGestureRecognizerStateBegan
UIGestureRecognizerStateEnded
UIGestureRecognizerStateCancelled
UIGestureRecognizerStateFailed
.enable = NO 禁止交互
parentView.hidden= YES 同样可以将内部的手势禁止掉

图像
CGImageCreateWithImageInRect(image.CGImage, faceRect); //使用ciimage初始化会导致cgimage为null [注意]

视频
AVLayerVideoGravityResizeAspectFill 保持视频的宽高比并溢出填充
AVLayerVideoGravityResizeAspect 保持视频的宽高比并缩入填充
AVLayerVideoGravityResize 直接填满区域

多语言
在项目设置info下选择多语言, 在target下无法设置
NSLocalizedString("tip",nil);
多语言配置 "tip"="xxxxxx";

系统
[UIApplication sharedApplication].idleTimerDisabled = YES; 长时间亮屏
复制到剪贴板
http://www.jianshu.com/p/9d84c70b9742

动画
CGAffineTransformIdentity 恢复原位
CGAffineTransformMakeTranslation(0, 10.0f) 偏移

app内部资源
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"sample_iPod" withExtension:@"m4v"];

app内部Documents资源
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];

延迟(多线程)
http://www.chengxuyuans.com/Android/84698.html
延时函数(NSTimer、performSelector和dispatch_after区别)
http://blog.csdn.net/sos5403/article/details/52438348

storyboard
创建navigation导航的时候需要看看 http://blog.csdn.net/chy555chy/article/details/51692279
从stroyboard创建uiviewcontroller并不调用init函数 http://blog.csdn.net/kyfxbl/article/details/17579565

使用alert作为输入框
http://blog.csdn.net/luofutongxin/article/details/48734323
自定义弹出输入框
http://www.jianshu.com/p/adc4273adeea
https://github.com/wozyao/ZYInputAlert

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容