20day-、UI综合练习(网易彩票)---知识点储备
来源:互联网 发布:上证指数算法 编辑:程序博客网 时间:2024/06/06 03:23
代码
UI综合练习-网易彩票
1、自定义UITarBarController 和TabBar
1)如何自定义TarBar-- 为了减小iOS系统版本间的风格差异首先要自定义UITabBarController:新建一个类,继承自UITabBarController
自定义TabBar
新建一个类,继承自UIView,用来做TabBar,封装内部的按钮在自定义的UITabBarController中创建自定义的TabBar,添加到默认的UITabBar上面
2、自定义导航栏控制器
1)自定义导航控制器的价值
重写push方法就可以拦截所有压入栈中的子控制器,统一做一些处理- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ [viewController setHidesBottomBarWhenPushed:YES];//隐藏BottomBar [super pushViewController:viewController animated:animated];}
重写pop方法就可以拦截所有子控制器的出栈- (UIViewController *)popViewControllerAnimated:(BOOL)animated;
2)导航栏主题的设置
主要是取得导航栏的appearance对象,操作它就设置导航栏的主题
UINavigationBar *navBar = [UINavigationBar appearance];
设置导航条主题 Expand source
/* @protocol UIAppearance <NSObject> 协议的代理方法+ (instancetype)appearance; @interface UIView : UIResponder < UIAppearance> */ UINavigationBar *navigationBar =[UINavigationBar appearance];//获取所有导航条外观 [navigationBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
导航条的兼容问题
//方式一:获取全局外观// UINavigationBar *navigationBar =[UINavigationBar appearance];//获取所有导航条外观 //方式二:获取我们自己导航控制器的导航条 UINavigationBar *navigationBar;//确保系统的其它功能(短信)的导航条与自己的冲突,尤其在短信分享这方面要注意 if (IOS9) { //9.0的API navigationBar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[HLNavigationController class]]]; }else{ navigationBar = [UINavigationBar appearanceWhenContainedIn:[HLNavigationController class],nil]; }
常用主题设置*导航栏背景:- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics; *标题:@property(nonatomic,copy) NSDictionary *titleTextAttributes;// 字典中能用到的key在UIStringDrawing.h中// 最新版本的key在UIKit框架的NSAttributedString.h中
设置文字颜色
NSDictionary *dict = @{NSForegroundColorAttributeName:[UIColor whiteColor]};[navigationBar setTitleTextAttributes:dict];//2、The tint color to apply to the navigation items and bar button items. 导航条的主题颜色 [navigationBar setTintColor:[UIColor whiteColor]];
*返回按钮的箭头样式@property(nonatomic,retain) UIColor *tintColor;
3)导航栏按钮主题
UIBarButtonItem *item = [UIBarButtonItem appearance];设置主题的方法:背景:- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics;文字:- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state;导航栏返回按钮背景:- (void)setBackButtonBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics;
+ (void) settingbarButtonItenAppearance{ //2、The tint color to apply to the navigation items and bar button items. 导航条的主题颜色 // [navigationBar setTintColor:[UIColor whiteColor]]; /** NS_CLASS_AVAILABLE_IOS(2_0) @interface UIBarItem : NSObject <NSCoding, UIAppearance> */ //导航栏按钮主题 UIBarButtonItem *barButtonIten = [UIBarButtonItem appearance]; /* 设置主题的方法: 背景:- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics; 文字:- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state; 导航栏返回按钮背景:- (void)setBackButtonBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics; */ [barButtonIten setTintColor:[UIColor whiteColor]]; [barButtonIten setBackgroundImage:[UIImage imageNamed:@"NavButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [barButtonIten setBackgroundImage:[UIImage imageNamed:@"NavButtonPressed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault]; [barButtonIten setBackButtonBackgroundImage:[UIImage imageNamed:@"NavBackButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [barButtonIten setBackButtonBackgroundImage:[UIImage imageNamed:@"NavBackButtonPressed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];}
4)导航栏背景的出图规格
retina 屏幕下的点= 像素/2。
iOS6导航栏背景的出图规格非retina:320x44 px retina:640x88 pxiOS7导航栏背景的出图规格retina:640x128 px
导航条主题的系统兼容
if ([UIDevice currentDevice].systemVersion.floatValue>=7.0) {//2016-04-25 15:38:43.112 HisunLottery[4141:217528] 9.2 [navigationBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];}else{ [navigationBar setBackgroundImage:[UIImage imageNamed:@"NavBar"] forBarMetrics:UIBarMetricsDefault];}
琐碎的知识点
1、为了在push控制器时隐藏UITabBar,需要做以下设置:
viewController.hidesBottomBarWhenPushed = YES;
2、ninitailize、load方法的区别:
initailize、load都是类方法当一个类被装载进内存时,就会调用一次load方法(当时这个类还不可用)当第一次使用这个类时,就会调用一次initailize方法
3、状态栏交给了UIApplication管理
要修改info.plist的viewController based status bar appearance 属性
<key>UIViewControllerBasedStatusBarAppearance</key><false/>
4、、去除图标的玻璃质感效果
取消苹果自动添加高亮特效。
苹果默认会在 App Store 里的应用图标上半部自动添加高亮特效,虽是好心但有时候这半个光圈会破坏图标设计者的原作。如果您要去掉这一高亮特效,可以在程序的 info.plist 里添加一个值类型为 boolean 的字段:UIPrerenderedIcon,值设定为YES(或者是:Icon already includes gloss effects,值设定为YES)。 再上传应用,App Store 就不会在图标上添加高亮特效了<key>UIPrerenderedIcon</key> <true/>
5、UIImageView的图片拉伸
UIImaegView的图片拉伸可以通过storyboard或者xib设置
x =0.5=右边的一半不拉伸,y= 0.5,距离顶部的一半不拉伸,width=0.00001 拉伸的像素 height= 0.0000001 拉伸的像素
UIButton不能通过storyboard或者xib设置,必须通过代码
// UIImage+ResizableImage.m// 20160525-QQinterface//// Created by devzkn on 3/26/16.// Copyright © 2016 hisun. All rights reserved.//#import "UIImage+ResizableImage.h"@implementation UIImage (ResizableImage)#pragma mark - 获取可拉伸图片/** 创建“指定拉伸方式和拉伸小矩形”的图片 */+ (UIImage*)resizableImageWithName:(NSString *)name { UIImage *image = [UIImage imageNamed:name]; //裁剪图片方式一: //Creates and returns a new image object with the specified cap values. /*right cap is calculated as width - leftCapWidth - 1 bottom cap is calculated as height - topCapWidth - 1 */ return [image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5]; //方式二: // CGFloat top = image.size.width*0.5f-1; // CGFloat left = image.size.height*0.5f-1; // UIEdgeInsets insets = UIEdgeInsetsMake(top, left, top, left); // UIImage *capImage = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeTile]; //}
阅读全文
0 0
- 20day-、UI综合练习(网易彩票)---知识点储备
- 20day-、UI综合练习(网易彩票)---主要代码和对应的业务分析
- 20day-、针对UI综合练习(网易彩票)的总结
- 练习:网易彩票项目知识点
- 综合设计ui 彩票设计设置界面
- 综合知识点练习
- iOS菜鸟成长笔记(2)——网易彩票练习
- 综合设计ui 彩票设计基础界面搭建
- 综合设计ui 彩票设计json 和 html添加
- 牛客网练习知识点笔记——综合
- 牛客网练习知识点笔记——综合
- 网易彩票项目思路
- 仿网易彩票思路
- 网易彩票项目总结
- 网易彩票,转盘实现
- 猫猫学iOS(四十六)之网易彩票幸运大转盘
- 彩票案例-封装知识点
- 彩票案例-知识点补充
- PHP大整数求和-arr
- 分区表数据快速迁移
- 再见,2017上半年!异步新书全盘点,下半年哪本书让你最期待?参与送书
- spring-data-redis
- Linux+Python+Apahce+wsgi
- 20day-、UI综合练习(网易彩票)---知识点储备
- spring mvc 常用注解标签详解(转载luojinfu7)
- USB CDC 类
- flume架构与核心组件源代码分析
- 正则表达式验证邮箱地址
- A20 看门狗使用注意事项
- G(1945): 最简单的题目
- P1137 旅行计划
- 第1章 JavaScript 简介