ios 常用放法、设置
2016-07-25 09:51
465 查看
//状态栏高度
CGFloat statusBarH = [[UIApplication sharedApplication] statusBarFrame].size.height;
//导航栏高度
CGFloat navigationBarH = self.navigationController.navigationBar.frame.size.height;
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//设置导航栏背景颜色
self.navigationController.navigationBar.barTintColor = RGBA(46, 148, 255, 1);
//设置导航栏标题字体大小、颜色
[[self.navigationController navigationBar] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[UIColor whiteColor]}];
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//键盘回收
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if (![touch.view isKindOfClass: [UITextField class]] || ![touch.view isKindOfClass: [UITextView class]]) {
[self.view endEditing:YES];
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//动画退出
- (void)exitApplication {
AppDelegate *app = [UIApplication sharedApplication].delegate;
UIWindow *window = app.window;
[UIView animateWithDuration:0.5f animations:^{
window.alpha = 0;
window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
} completion:^(BOOL finished) {
exit(0);
}];
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//UILabel 字体居中设置
label.textAlignment = NSTextAlignmentCenter;
CGFloat statusBarH = [[UIApplication sharedApplication] statusBarFrame].size.height;
//导航栏高度
CGFloat navigationBarH = self.navigationController.navigationBar.frame.size.height;
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//设置导航栏背景颜色
self.navigationController.navigationBar.barTintColor = RGBA(46, 148, 255, 1);
//设置导航栏标题字体大小、颜色
[[self.navigationController navigationBar] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[UIColor whiteColor]}];
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//键盘回收
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if (![touch.view isKindOfClass: [UITextField class]] || ![touch.view isKindOfClass: [UITextView class]]) {
[self.view endEditing:YES];
}
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//动画退出
- (void)exitApplication {
AppDelegate *app = [UIApplication sharedApplication].delegate;
UIWindow *window = app.window;
[UIView animateWithDuration:0.5f animations:^{
window.alpha = 0;
window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
} completion:^(BOOL finished) {
exit(0);
}];
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
//UILabel 字体居中设置
label.textAlignment = NSTextAlignmentCenter;
相关文章推荐
- iOS开发——创建你自己的Framework
- 3d Touch基本应用
- iOS中获取各种文件的目录路径的方法
- iOS开发使用半透明模糊效果方法整理
- 怎么申请299$的企业开发者帐号 申请的时候应该选择哪个?
- iOS开发的一些奇巧淫技
- IOS将异常输出到日志
- iOS中集成ijkplayer视频直播框架
- 关于IOS开发常见的循环引用问题
- iOS里CALayer的使用
- Xcode各版本官方下载及百度云盘下载, Mac和IOS及Xcode版本历史. (2015-07-17 07:05:06)
- iOS开发75-leaks will report false positives while the environment variable NSZombiesEnable is active的解
- iOS中的imageIO与image解码
- iOS对textField进行字符长度限制的办法
- iOS开发74-XCode(7.3.1)使用Instruments(7.3.1)测试内存泄漏例子(循环引用)
- WWDC2016 Session笔记 - Xcode 8 Auto Layout新特性
- ios memset EXC_BAD_ACCESS
- iOS 分享的半透明界面
- iOS 编程思想 链式编程思想
- 一文让你彻底了解iOS字体相关知识