DetailsViewCell
来源:互联网 发布:mac os 10.8.5升级 编辑:程序博客网 时间:2024/06/01 12:36
#import <UIKit/UIKit.h>
@interface DetailsViewCell : UITableViewCell
{
//灰色背景
UIView *_lab_BgView;
UILabel *_lab_Mask;
//正常状态
UILabel *_lab_Title;
//伸开状态
UILabel *_lab_Summary;
}
@property (retain,nonatomic)UILabel *lab_Title;
@property (retain,nonatomic)UILabel *lab_Summary,*lab_Mask;
-(CGFloat)heightForSummaryLabel;
@end
#define CELLHEIGHT 50
@implementation DetailsViewCell
@synthesize lab_Summary=_lab_Summary;
@synthesize lab_Title=_lab_Title,lab_Mask=_lab_Mask;
//
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_lab_BgView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
[self insertSubview:_lab_BgView belowSubview:self.imageView];
//
_lab_Mask=[[UILabel alloc]init];
[self insertSubview:_lab_Mask belowSubview:_lab_Mask];
//title
_lab_Title=[[UILabel alloc]init];
[self.contentView addSubview:_lab_Title];
//Summary
_lab_Summary=[[UILabel alloc]init];
_lab_Summary.numberOfLines=0;
_lab_Summary.lineBreakMode=NSLineBreakByWordWrapping;
_lab_Summary.textColor=[UIColor colorWithRed:78.0/256 green:78.0/256 blue:78.0/256 alpha:1.0];
_lab_Summary.font=[UIFont fontWithName:@"Arial" size:12];
[self.contentView addSubview:_lab_Summary];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)drawRect:(CGRect)rect
{
[super drawRect:rect];
_lab_BgView.backgroundColor=[UIColor colorWithRed:236.0/266 green:234.0/266.0 blue:227.0/256 alpha:1.0];
_lab_BgView.alpha=0.3;
_lab_Mask.backgroundColor=[UIColor colorWithRed:236.0/266 green:234.0/266.0 blue:227.0/256 alpha:1.0];
_lab_Mask.alpha=0.3;
//
_lab_Title.backgroundColor=[UIColor clearColor];
_lab_Summary.backgroundColor=[UIColor clearColor];
}
-(CGFloat)heightForSummaryLabel
{
if (_lab_Summary.text !=nil )
{
CGSize sizeForFit=CGSizeMake(self.frame.size.width-CELLHEIGHT-40, 300);
UIFont *fontForFit=[UIFont fontWithName:@"Arial" size:12];
CGSize textSize=[_lab_Summary.text sizeWithFont:fontForFit constrainedToSize:sizeForFit lineBreakMode:NSLineBreakByWordWrapping];
return textSize.height+10;
}else{
return 0;
}
}
-(void)layoutSubviews
{
[super layoutSubviews];
//灰色背景
[_lab_BgView setFrame:CGRectMake(10, 0, CELLHEIGHT, CELLHEIGHT)];
//imageView center
CGPoint p=CGPointMake(CELLHEIGHT/2.0, CELLHEIGHT/2.0-3);
self.imageView.center=p;
//详细页面左边的灰色
[_lab_Mask setFrame:CGRectMake(10, CELLHEIGHT, CELLHEIGHT, self.frame.size.height-CELLHEIGHT)];
//详细页面title内容
[_lab_Title setFrame:CGRectMake(CELLHEIGHT+12, 0, self.frame.size.width-CELLHEIGHT-35, CELLHEIGHT)];
//详细页面summary内容
[_lab_Summary setFrame:CGRectMake(CELLHEIGHT+12, CELLHEIGHT-8, self.frame.size.width-CELLHEIGHT-35, [self heightForSummaryLabel])];
//
}
@end
- DetailsViewCell
- zoj 2401
- Windows下的Memcache安装与测试教程
- Android linker 详解
- kthread_create 简单使用
- SQLite error,no such table的处理方法
- DetailsViewCell
- 泛型如何获取类
- Git通过代理连接外网
- linux 命令行下,oracle数据库的导入、导出命令
- windowsCE异常和中断服务程序初探(-)
- linux下ganglia监控系统搭建
- Step By Step系列之Fragments(一)
- [iOS]关于在程序里面点击进入app store并自动显示搜索应用,自动显示某个公司的app stroe应用列表
- HTTP错误代码汇总