IOS - 购买类型视图

标签: MystraIOS视图购买类型
788人阅读 评论(0) 收藏 举报
分类:

购买类型视图定制


代码

// 支付页面格式
- (UIView*) CellForRowAtRow:(NSInteger) row {

    UIView* itemView = [UIView viewWithFrame: CGRectMake(0, 0, viewWidth() - 20, 45)
                                  andBkColor: [UIColor clearColor]];

    NIDASSERT(row < _alipayInfo.count);
    if (row < _alipayInfo.count) {

        // 会员包年包月
        UILabel* titleLabel = [UILabel labelWithFrame: CGRectMake(10, 15, 100, 15)
                                             fontSize: 14
                                            fontColor: RGBCOLOR_HEX(0x666666)
                                                 text: _alipayInfo[row][@"desc"]];
        [itemView addSubview: titleLabel];

        // 价钱
        CYAttributedLabel* pricelabel = [[CYAttributedLabel alloc] initWithFrame: CGRectMake(0, 12, 125, 20)];
        pricelabel.verticalTextAlignment = NIVerticalTextAlignmentTop;
        pricelabel.text = [NSString stringWithFormat: @"%@元", _alipayInfo[row][@"price"]];
        pricelabel.font = [UIFont boldSystemFontOfSize: 14];
        pricelabel.textColor = RGBCOLOR_HEX(0xff6000);

        [pricelabel setFont: [UIFont boldSystemFontOfSize: 11]
                      range: [pricelabel.text rangeOfString: @"元"]];
        pricelabel.textAlignment = NSTextAlignmentRight;
        [itemView addSubview: pricelabel];

        // 和原价的比较
        CYAttributedLabel* originPriceLabel = [[CYAttributedLabel alloc] initWithFrame: CGRectMake(145, 16, 110, 18)];
        originPriceLabel.font = [UIFont systemFontOfSize: 11];
        originPriceLabel.verticalTextAlignment = NIVerticalTextAlignmentTop;
        originPriceLabel.cssHandler = [CYResource getCssHandler];
        originPriceLabel.text = _alipayInfo[row][@"old_price"];
        originPriceLabel.textColor = RGBCOLOR_HEX(0x666666);

        [itemView addSubview: originPriceLabel];

        NSArray *array = [originPriceLabel.text componentsSeparatedByString:@" "];

        // 划线
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = originPriceLabel.textColor;
        [itemView addSubview:lineView];

        UILabel *subLabel = [UILabel labelWithFrame:CGRectZero
                                           fontSize:14
                                          fontColor:[UIColor blackColor]
                                               text:array[0]];
        [subLabel sizeToFit];
        lineView.frame = CGRectMake(originPriceLabel.left, originPriceLabel.top + 7, subLabel.width - 10, 1);

        // 选中的按钮
        UIButton* button = [UIButton buttonWithBackgroundImage: @"choose_icon_normal.png"
                                       selectedBackgroundImage: @"choose_icon_selected.png"
                                                         frame: CGRectMake(viewWidth() - 50, 14, 20, 20)
                                                        target: nil
                                                      selector: nil];
        [itemView addSubview: button];
    }

    return itemView;
}

效果
效果


娱乐

2
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2491434次
    • 积分:32494
    • 等级:
    • 排名:第152名
    • 原创:709篇
    • 转载:1篇
    • 译文:0篇
    • 评论:385条
    自我简介

    本人代码娴熟,涉猎广泛。

    目前任职于春雨医生的大数据部,数据挖掘工程师。

    曾经任职于春雨医生的移动端部,高级Android开发工程师。

    欢迎Follow我的GitHub:.

    https://github.com/SpikeKing

    文章分类
    最新评论