标签:arm nts white __bridge orb play state 背景图片 ext
1. 新建UIViewController:Arena(竞技场)->Controller->Cocoa Touch Class->Class:HMArenaController;Subclass of:UIViewController
2. 设置“Arena.storyboard”文件的类为“HMArenaController”:Custom Class->Class:HMArenaController
3. 设置导航栏标题:拖进控件Segmented Control->Segment 0:足球;Segment 1:篮球
4. 在“HMArenaController.m”文件的“viewDidLoad”方法中设置控制器拉伸风格的背景图片,代码如下:
//设置控制器的背景图片(拉伸) self.view.layer.contents = (__bridge id)[UIImage imageNamed:@"NLArenaBackground"].CGImage;
5. 在“HMArenaController.m”文件的“viewDidLoad”方法中设置导航栏的背景图片,代码如下:
//设置 navbar 的图片 [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NLArenaNavBar64"] forBarMetrics:UIBarMetricsDefault];
6. 在“HMArenaController.m”文件的“viewDidLoad”方法中设置导航栏标题属性,代码如下:
//获取 titleView UISegmentedControl* seg = (UISegmentedControl*)self.navigationItem.titleView; //设置默认的背景图片 [seg setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentBG"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; //设置选中的背景图片 [seg setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentSelectedBG"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault]; //设置文字的颜色 [seg setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] } forState:UIControlStateNormal]; [seg setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] } forState:UIControlStateSelected]; //取消蓝色的线 [seg setTintColor:[UIColor clearColor]];
标签:arm nts white __bridge orb play state 背景图片 ext
原文地址:https://www.cnblogs.com/diexin/p/9825650.html