瀑布流接口的设计以及应用(四)

//
//  MyShopCell.h
//  瀑布流
//
//  Created by Jose on 15-7-12.
//  Copyright (c) 2015年 Jose. All rights reserved.
//


#import "MyWaterFlowViewCell.h"
@class MyWaterFlowView,MyShop;


@interface MyShopCell : MyWaterFlowViewCell
+(instancetype)cellWithWaterFlowView:(MyWaterFlowView *)mywaterflowview;
@property(nonatomic,strong)MyShop *shop;

@end



**************************************************************************************************************

*************************************************************************************************************

*************************************************************************************************************

//
//  MyShopCell.m
//  瀑布流
//
//  Created by Jose on 15-7-12.
//  Copyright (c) 2015年 Jose. All rights reserved.
//


#import "MyShopCell.h"
#import "MyWaterFlowView.h"
#import "MyShop.h"
#import "UIImageView+WebCache.h"




@interface MyShopCell()
/**显示商品的图片*/
@property(nonatomic,weak)UIImageView *imageview;
/**显示商品的价格*/
@property(nonatomic,weak)UILabel *pricelabel;
@end
@implementation MyShopCell


-(id)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        
        //设置显示图片的控件
        UIImageView *imageview=[[UIImageView alloc]init];
        [self addSubview:imageview];
        self.imageview=imageview;
        
        //设置价格的控件
        UILabel *label=[[UILabel alloc]init];
        label.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        label.textAlignment=NSTextAlignmentCenter;
        label.textColor=[UIColor whiteColor];
        [self addSubview:label];
        self.pricelabel=label;
    }
    return self;
}


+(instancetype)cellWithWaterFlowView:(MyWaterFlowView *)mywaterflowview{
    static NSString *ID=@"shop";
    MyShopCell *cell=[mywaterflowview dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell=[[MyShopCell alloc]init];
        cell.identifier=ID;
    }
    return cell;
}


//通过set进行赋值
-(void)setShop:(MyShop *)shop{
    _shop=shop;
    self.pricelabel.text=shop.price;
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:shop.img] placeholderImage:[UIImage imageNamed:@"loading"]];
}


-(void)layoutSubviews{
    [super layoutSubviews];
    self.imageview.frame=self.bounds;
    CGFloat pricex=0;
    CGFloat priceh=25;
    CGFloat pricey=self.bounds.size.height-priceh;
    CGFloat pricew=self.bounds.size.width;
    self.pricelabel.frame=CGRectMake(pricex, pricey, pricew, priceh);
}
@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值