首页 > 其他 > 详细

创建一个没有边框的并添加自定义文字的UISegmentedControl

时间:2015-12-02 16:10:23      阅读:368      评论:0      收藏:0      [点我收藏+]

    //个性推荐 歌单 主播电台 排行榜

    NSArray* promoteArray=@[@"个性推荐",@"歌单",@"主播电台",@"排行榜"];

    UISegmentedControl* promoteSgement=[[UISegmentedControl alloc]initWithItems:promoteArray];

    promoteSgement.frame=CGRectMake(0, 64, screenWidth, 40);

    [promoteSgement setSelectedSegmentIndex:0];//默认选择第一个

    promoteSgement.tintColor = [UIColor clearColor];//去掉颜色 现在整个segment都看不见

    NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:[UIColor colorWithRed:212/256.0 green:21/256.0 blue:10/256.0 alpha:1]};

    [promoteSgement setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];//设置选择时文字的属性

    NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName: [UIColor blackColor]};

    [promoteSgement setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];//设置未选择时文字的属性

    [self.view addSubview:promoteSgement];

创建一个没有边框的并添加自定义文字的UISegmentedControl

原文:http://www.cnblogs.com/death3721/p/5013268.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!