Xcode 代码片段

UISegmentedControl 分段控制器选中切换

2018-12-14  本文已影响0人  _YN

//默认选中

_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)

上一篇 下一篇

猜你喜欢

热点阅读