美文网首页Xcode 代码片段
UISegmentedControl 分段控制器选中切换

UISegmentedControl 分段控制器选中切换

作者: _YN | 来源:发表于2018-12-14 11:37 被阅读0次

//默认选中

_segment.selectedSegmentIndex = 0;

//选择时的颜色和字体   

[_segment setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName: [UIColor blueColor]} forState:UIControlStateSelected];

//未选择时的颜色和字体

[_segment setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];

//区分在那个选项

[_segment addTarget:self action:@selector(SegClick:) forControlEvents:UIControlEventValueChanged];

if (seg.selectedSegmentIndex == 0)

[如果您在阅读我的文章时有疑问 , 请点击这里](https://www.jianshu.com/p/1e68be1e6646)

相关文章

网友评论

    本文标题:UISegmentedControl 分段控制器选中切换

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