码迷,mamicode.com
首页 > 其他好文 > 详细

button形式的四四方方的cell(有分割线)

时间:2016-03-14 18:45:52      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

    UIView *btnBgView = [[UIView alloc] initWithFrame:CGRectMake(edge, topView.bottom + kNormalSectionInset, topView.width, 252 * kScreenScale)];
    btnBgView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:btnBgView];
    self.btnBgView = btnBgView;

    NSArray *btnInfoArr = @[
                            @{
                                @"image":@"home_store",
                                @"title":NSLocalizedString(@"我的店铺", nil),
                                @"tag":@(YSBadgeButtonTypeStore)
                                },
                            @{
                                @"image":@"home_items",
                                @"title":NSLocalizedString(@"商品管理", nil),
                                @"tag":@(YSBadgeButtonTypeItems)
                                },
                            @{
                                @"image":@"home_order",
                                @"title":NSLocalizedString(@"我的订单", nil),
                                @"tag":@(YSBadgeButtonTypeOrder)
                                },
                            @{
                                @"image":@"home_meg",
                                @"title":NSLocalizedString(@"通知", nil),
                                @"tag":@(YSBadgeButtonTypeMessage)
                                }
                            ];

    float btnWidth = (btnBgView.width / 2);
    float btnHeight = (btnBgView.height / 2);
    [btnInfoArr enumerateObjectsUsingBlock:^(NSDictionary *info, NSUInteger idx, BOOL *stop) {
        YSBadgeButton *btn = [YSBadgeButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(btnWidth * (idx % 2), btnHeight * (idx / 2), btnWidth, btnHeight);
        [btn setImage:[UIImage imageNamed:info[@"image"]] forState:UIControlStateNormal];
        [btn setTitle:info[@"title"] forState:UIControlStateNormal];
        btn.titleLabel.font = kHomeViewFont;
        btn.tag = [info[@"tag"] intValue];
        [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];
        [btnBgView addSubview:btn];
    }];
    
    // 分割线
    UIView *verticalLine = [YSUtils verticallineViewWithFrame:CGRectMake(_btnBgView.width / 2.0 - 0.5, 0, 1, _btnBgView.height)];
    [_btnBgView addSubview:verticalLine];
    
    UIView *horizontalLine = [YSUtils lineViewWithFrame:CGRectMake(0, _btnBgView.height / 2.0 - 0.5, _btnBgView.width, 1)];
    [_btnBgView addSubview:horizontalLine];

button形式的四四方方的cell(有分割线)

标签:

原文地址:http://www.cnblogs.com/Lucky-056150/p/5276414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!