zoukankan      html  css  js  c++  java
  • button形式的四四方方的cell(有分割线)

       

    NO1:

    From: 项目:Dongdaemun ➡️ ViewController 文件夹 ➡️ 主界面 ➡️ YSHomeViewController.m 中

    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];

    NO2:

     UIView *lineOne = [[UIView alloc]initWithFrame:CGRectMake(125, 0, 1.0/[UIScreen mainScreen].scale, 80)];
                lineOne.backgroundColor = [UIColor grayColor];
                [cell.contentView addSubview:lineOne];
                
                [cell addSubview:self.btnPack];

    UIView *lineTwo = [[UIView alloc]initWithFrame:CGRectMake(250, 0, 1.0/[UIScreen mainScreen].scale, 80)];
                lineTwo.backgroundColor = [UIColor grayColor];
                [cell.contentView addSubview:lineTwo];
                
                [cell addSubview:self.btnNum];

  • 相关阅读:
    总结ASP.NET C#中经常用到的13个JS脚本代码
    C# 处理 JSON 常用的帮助类
    C# 中移动文件到指定位置
    C# 常用时间戳处理方法
    c#批量上传图片到服务器示例分享
    C# 通过URL获取图片并显示在PictureBox上的方法
    QT中Qtableview视图表格中点击表头进行排序
    qt QTableWidget&&QTableView 导出数据到excel
    51nod 1242 斐波那契数列的第N项
    矩阵快速幂
  • 原文地址:https://www.cnblogs.com/Lucky-056150/p/5276414.html
Copyright © 2011-2022 走看看