美文网首页
UISegment 设置样式(背景颜色,字体颜色)

UISegment 设置样式(背景颜色,字体颜色)

作者: 原味丿丿咖啡Vitas | 来源:发表于2019-03-08 17:54 被阅读0次
        self.segment.tintColor = [UIColor colorWithRGB:0xE8985E];
        self.segment.layer.cornerRadius = 17.0;
        self.segment.clipsToBounds = YES;
        [self.segment setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRGB:0xDEDEDE]] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        [self.segment setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRGB:0xE8985E]] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
        NSDictionary *normalDic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRGB:0x999999],NSForegroundColorAttributeName,nil];
        [self.segment setTitleTextAttributes:normalDic forState:UIControlStateNormal];
        NSDictionary *selectDic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil];
        [self.segment setTitleTextAttributes:selectDic forState:UIControlStateSelected];
    

    效果如下

    image.png

    相关文章

      网友评论

          本文标题:UISegment 设置样式(背景颜色,字体颜色)

          本文链接:https://www.haomeiwen.com/subject/hchdpqtx.html