第三方NYSegmentedControl 的使用
github地址
https://github.com/nealyoung/NYSegmentedControl
#import "NYSegmentedControl.h"
NYSegmentedControl *_segement;
NSArray *_buttons;
_buttons = [NSArray arrayWithObjects:@"推荐阅读",@"我的订阅", nil];
_segement = [[NYSegmentedControl alloc] initWithItems:_buttons];
[_segement setBorderWidth:2.f * 0.618f];
[_segement setBorderColor:[UIColor colorWithWhite:1.f alpha:1.0f]];
[_segement setSegmentIndicatorInset:0.618f];
[_segement setDrawsSegmentIndicatorGradientBackground:YES];
[_segement setSegmentIndicatorGradientTopColor:[UIColor redColor]];
[_segement setSegmentIndicatorGradientBottomColor:[UIColor redColor]];
[_segement setSegmentIndicatorAnimationDuration:0.3f];
[_segement.layer setCornerRadius:15.f];
[_segement setTitleTextColor:[UIColor blackColor]];
[_segement setSelectedTitleTextColor:[UIColor whiteColor]];
[_segement setFrame:CGRectMake(0, 0, 200, 30)];
[_segement setSelectedSegmentIndex:0];
[_segement addTarget:self action:@selector(segementPressed:) forControlEvents:UIControlEventValueChanged];
[self.navigationItem setTitleView:_segement];