您的位置:首页 > 其它

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

2015-07-15 22:57 267 查看
//

// 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: