zoukankan      html  css  js  c++  java
  • 利用layer设置背景图片以及NSForegroundColorAttributeName设置颜色

    @property (weak, nonatomic) IBOutlet UISegmentedControl *Sgment;
    
    @end
    
    @implementation ArenaViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        //设置控制器view的背景图片
        self.view.layer.contents = (__bridge id)([UIImage imageNamed:@"NLArenaBackground"].CGImage);
    
        //设置segument普通状态下的的背景图片
        
        [self.Sgment setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentBG"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        
        //设置segument选中状态下的的背景图片
        [self.Sgment setBackgroundImage:[UIImage imageNamed:@"CPArenaSegmentSelectedBG"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
    
        //设置segument的文字颜色
        NSDictionary *attri = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
        //默认情况下
        [self.Sgment setTitleTextAttributes:attri forState:UIControlStateNormal];
        //选中情况下
        [self.Sgment setTitleTextAttributes:attri forState:UIControlStateSelected];
    
    
    }
  • 相关阅读:
    qiankun 报错:Target container with #container not existed while xxx mounting!
    promise加载队列实现
    promise 封装定时器
    关于promise
    节流防抖
    箭头函数特点
    this
    手写apply
    手写call
    手写bind函数
  • 原文地址:https://www.cnblogs.com/ZMiOS/p/5018862.html
Copyright © 2011-2022 走看看