HMSegmentedControl的使用



下载地址:https://github.com/HeshamMegid/HMSegmentedControl  


    HMSegmentedControl *segmented = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"已收公告",@"已发公告"]];
    segmented.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth; // 自动调整
    segmented.frame = CGRectMake(self.view.bounds.size.width/2-100, 4, 200, 40);
    segmented.backgroundColor = [UIColor clearColor];
    segmented.selectionIndicatorHeight = 3.0f;  // 线的高度
    segmented.font = [UIFont fontWithName:@"STHeitiSC-Light" size:19.0f];  // 设置字体
    segmented.textColor = WHRGB(255, 175, 185);   // 字的颜色
    segmented.selectedTextColor = [UIColor whiteColor]; // 选中时字体颜色
    segmented.selectionIndicatorColor = [UIColor whiteColor];  //线条的颜色
    segmented.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe; //线充满整个长度
    segmented.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown; //线的位置
    [segmented addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
    self.segmentedControl = segmented;
    [self.navigationController.navigationBar addSubview:segmented];</span>



typedef enum {  //线的样式

    HMSegmentedControlSelectionStyleTextWidthStripe,// Indicator width will only be as big as the text width


    HMSegmentedControlSelectionStyleFullWidthStripe,// Indicator width will fill the whole segment


    HMSegmentedControlSelectionStyleBox, // A rectangle that covers the whole segment


    HMSegmentedControlSelectionStyleArrow // An arrow in the middle of the segment pointing up or down depending on `HMSegmentedControlSelectionIndicatorLocation`


} HMSegmentedControlSelectionStyle;


typedef enum {  // 线的位置

    HMSegmentedControlSelectionIndicatorLocationUp,


    HMSegmentedControlSelectionIndicatorLocationDown,

HMSegmentedControlSelectionIndicatorLocationNone// No selection indicator

} HMSegmentedControlSelectionIndicatorLocation;



//  边缘的样式

property (nonatomic,assign) HMSegmentedControlBorderType borderType;


/**

 Specifies the border color.

 

 Default is `[UIColor blackColor]`

 */

@property (nonatomic,strong) UIColor *borderColor;


/**

 Specifies the border width.

 

 Default is `1.0f`

 */

@property (nonatomic,assign) CGFloat borderWidth;





// 设置内容

@property (nonatomic,strong) NSArray *sectionTitles;

@property (nonatomic,strong) NSArray *sectionImages;

@property (nonatomic,strong) NSArray *sectionSelectedImages;


// 判断点击是哪个

@property (nonatomic,assign) NSInteger selectedSegmentIndex;


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值