Latest 1.0.1
Homepage https://github.com/nhfc99/NHFRadioButton
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation, CoreGraphics, UIKit
Authors

介绍

这是一个自由度非常大的单选框按钮组件

安装

  • pod ‘NHFRadioButton’
  • 手动下载然后将文件夹拖至工程中即可

使用方法

    CGFloat everyHeight = 40.f;//每行的高度
    CGFloat everyLineBoth = 10.f;//行与行间的间距
    CGFlost bothSides = 15.f;//左边的视图与右边视图的间距(左边选择图片与后边的视图的间距)
    _nhfRadioButton = [[NHFRadioButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame), [DeviceInfo ScreenSize].width, (everyHeight+everyLineBoth)*2+everyLineBoth)
                                         NHFRadioButtonType:NHFRadioButtonTypeOnlyOneSelect
                                              everyLineBoth:everyLineBoth
                                                  bothSides:bothSides
                                    buttonWithRightViewBoth:10.f
                                       NHFRadioButtonAction:^(NSInteger item) {
                                       //这里回调选择的某行
                                           selectItem = item;
    }];
    [self addSubview:_nhfRadioButton];
    _nhfRadioButton.selectIco = [UIImage imageNamed:@"only_unselect_ico"];
    _nhfRadioButton.unSelectIcos = [UIImage imageNamed:@"only_select_ico"];
    NSMutableArray *rightViews = [NSMutableArray new];

    //微信
    UIView *wxView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [DeviceInfo ScreenSize].width-100, everyHeight)];
    [wxView setUserInteractionEnabled:false];
    [rightViews addObject:wxView];
    UIImageView *wxImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, everyHeight, everyHeight)];
    [wxImageView setImage:[UIImage imageWithContentsOfFile:[DeviceInfo AppBaseResourcePath:@"weixin_pay_ico.png"]]];
    [wxView addSubview:wxImageView];
    UILabel *wxLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(jinheImageView.frame)+MARGIN/2, 0, 100, everyHeight)];
    [wxLabel setFont:[UIFont fontByName:nil fontSize:16]];
    [wxLabel setText:@"微信支付"];
    [wxView addSubview:wxLabel];

    //支付宝
    UIView *zfbView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [DeviceInfo ScreenSize].width-100, everyHeight)];
    [zfbView setUserInteractionEnabled:false];
    [rightViews addObject:zfbView];
    UIImageView *zfbImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, everyHeight, everyHeight)];
    [zfbImageView setImage:[UIImage imageWithContentsOfFile:[DeviceInfo AppBaseResourcePath:@"zhifubao_pay_ico.png"]]];
    [zfbView addSubview:zfbImageView];
    UILabel *zfbLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(jinheImageView.frame)+MARGIN/2, 0, 100, everyHeight)];
    [zfbLabel setFont:[UIFont fontByName:nil fontSize:16]];
    [zfbLabel setText:@"微信支付"];
    [zfbView addSubview:zfbLabel];

    _nhfRadioButton.rightViews = rightViews;
    [_nhfRadioButton updateView];

Latest podspec

{
    "name": "NHFRadioButton",
    "version": "1.0.1",
    "summary": "u8fd9u662fu4e00u4e2au81eau7531u5ea6u975eu5e38u5927u7684u5355u9009u6846u6309u94aeu7ec4u4ef6",
    "homepage": "https://github.com/nhfc99/NHFRadioButton",
    "license": "MIT",
    "authors": {
        "u725bu5b8fu98de": "[email protected]"
    },
    "source": {
        "git": "https://github.com/nhfc99/NHFRadioButton.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "NHFRadioButton/*.{h,m}",
    "frameworks": [
        "Foundation",
        "CoreGraphics",
        "UIKit"
    ]
}

Pin It on Pinterest

Share This