19-项目实战(彩票02)

2016-04-08  本文已影响43人  木喳喳的夏天

知识点回顾

封装蒙版和活动菜单

+ (void)show
{
    
    // 创建蒙版对象
    XMGCover *cover = [[XMGCover alloc] initWithFrame:XMGScreenBounds];
    
    cover.backgroundColor = [UIColor blackColor];
    
    cover.alpha = 0.6;
    
    
    // 把蒙版对象添加主窗口
    [XMGKeyWindow addSubview:cover];
}
+ (void)hide
{
    for (UIView *childView in XMGKeyWindow.subviews) {
        if ([childView isKindOfClass:self]) {
            [childView removeFromSuperview];
        }
    }
}

自定义菜单

搭建竞技场

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    //
    UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@"足球",@"篮球"]];
    seg.width += 40;
    
    // 设置UISegmentedControl背景图片
    [seg setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentBG"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [seg setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentSelectedBG"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
    seg.selectedSegmentIndex = 0;
    // 0 142 143
    // 设置边框颜色
    seg.tintColor = XMGColor(0, 142, 143);
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [seg setTitleTextAttributes:dict forState:UIControlStateSelected];
    
    self.navigationItem.titleView = seg;
}
上一篇 下一篇

猜你喜欢

热点阅读