首页--HomePageCourseTableViewCell
#import
@interface HomePageCourseTableViewCell : UITableViewCell
@end
#import "HomePageCourseTableViewCell.h"
@implementationHomePageCourseTableViewCell
- (id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier
{
self= [superinitWithStyle:stylereuseIdentifier:reuseIdentifier];
if(self) {
UIScreen* mainScreen = [UIScreenmainScreen];
CGRectscrollFrame =CGRectMake(0,0, mainScreen.bounds.size.width,120);
UIScrollView* bgScrollView = [[UIScrollViewalloc]initWithFrame:scrollFrame];
bgScrollView.contentSize=CGSizeMake(mainScreen.bounds.size.width+110,120);
[self.contentViewaddSubview:bgScrollView];
//设置UITableCell的点击风格
self.selectionStyle = UITableViewCellSelectionStyleNone;
//自定义需要的内容
CGFloatwidth = mainScreen.bounds.size.width/3;
CGFloatheight =70;
//1.
UIImage* classOneImage = [UIImageimageNamed:@""];
UIButton* classOneBtn = [[UIButtonalloc]initWithFrame:CGRectMake(width*0,10, width, height)];
[classOneBtnsetImage:classOneImageforState:UIControlStateNormal];
[classOneBtnaddTarget:self action:@selector(showClassOneAction:) forControlEvents:UIControlEventTouchUpInside];
[bgScrollViewaddSubview:classOneBtn];
CGRectclassOneLabelFrame =CGRectMake(0,CGRectGetHeight(classOneBtn.frame),width ,15);
UILabel* classOneLabel = [[UILabelalloc]initWithFrame:classOneLabelFrame];
classOneLabel.textColor= [UIColorlightGrayColor];
classOneLabel.textAlignment=NSTextAlignmentCenter;
classOneLabel.font= [UIFontsystemFontOfSize:12];
classOneLabel.text = @"第一中学\n2016-2017第一中学";
classOneLabel.numberOfLines=0;
[classOneBtnaddSubview:classOneLabel];
//2.
UIImage* classTwoImage = [UIImageimageNamed:@""];
UIButton* classTwoBtn = [[UIButtonalloc]initWithFrame:CGRectMake(width*1,10, width, height)];
[classTwoBtnsetImage:classTwoImageforState:UIControlStateNormal];
[classTwoBtnaddTarget:self action:@selector(showClassTwoAction:) forControlEvents:UIControlEventTouchUpInside];
[bgScrollViewaddSubview:classTwoBtn];
CGRectclassTwoLabelFrame =CGRectMake(0,CGRectGetHeight(classTwoBtn.frame), width,15);
UILabel* classTwoLabel = [[UILabelalloc]initWithFrame:classOneLabelFrame];
classTwoLabel.textColor= [UIColorlightGrayColor];
classTwoLabel.textAlignment=NSTextAlignmentCenter;
classTwoLabel.font= [UIFontsystemFontOfSize:12];
classTwoLabel.text = @"第一中学\n2016-2017第一中学";
classTwoLabel.numberOfLines=0;
[classTwoBtnaddSubview: classTwoLabel];
//3.
UIImage* classThreeImage = [UIImageimageNamed:@""];
UIButton* classThreeBtn = [[UIButtonalloc]initWithFrame:CGRectMake(width*2,10, width, height)];
[classThreeBtnsetImage:classThreeImageforState:UIControlStateNormal];
[classThreeBtnaddTarget:self action:@selector(showClassThreeAction:) forControlEvents:UIControlEventTouchUpInside];
[bgScrollViewaddSubview:classThreeBtn];
CGRectclassThreeLabelFrame =CGRectMake(0,CGRectGetHeight(classThreeBtn.frame), width,15);
UILabel* classThreeLabel = [[UILabelalloc]initWithFrame:classThreeLabelFrame];
classThreeLabel.textColor= [UIColorlightGrayColor];
classThreeLabel.textAlignment=NSTextAlignmentCenter;
classThreeLabel.font= [UIFontsystemFontOfSize:12];
classThreeLabel.text=@"第一中学\n2016-2017第一中学";
classThreeLabel.numberOfLines=0;
[classThreeBtnaddSubview: classThreeLabel];
//4.
UIImage* classFourImage = [UIImageimageNamed:@""];
UIButton* classFourBtn = [[UIButtonalloc]initWithFrame:CGRectMake(width*3,10, width, height)];
[classFourBtnsetImage:classFourImageforState:UIControlStateNormal];
[classFourBtnaddTarget:self action:@selector(showClassFourAction:) forControlEvents:UIControlEventTouchUpInside];
[bgScrollViewaddSubview:classFourBtn];
CGRectclassFourLabelFrame =CGRectMake(0,CGRectGetHeight(classFourBtn.frame), width,15);
UILabel* classFourLabel = [[UILabelalloc]initWithFrame:classFourLabelFrame];
classFourLabel.textColor= [UIColorlightGrayColor];
classFourLabel.textAlignment=NSTextAlignmentCenter;
classFourLabel.font= [UIFontsystemFontOfSize:12];
classFourLabel.text=@"第一中学\n2016-2017第一中学";
classFourLabel.numberOfLines=0;
[classFourBtnaddSubview:classFourLabel];
}
return self;
}
- (void)showClassOneAction:(UIButton*)btn
{
NSLog(@"第一中学第一课");
}
- (void)showClassTwoAction:(UIButton*)btm
{
NSLog(@"第一中学第二课");
}
- (void)showClassThreeAction:(UIButton*)btn
{
NSLog(@"第一中学第三课");
}
-(void)showClassFourAction:(UIButton*)btn
{
NSLog(@"第一中学第四课");
【首页--HomePageCourseTableViewCell】}
推荐阅读
- Axure|Axure 教程(PC 端电商首页商品分类)
- LR.Net快速配置效率实用首页
- 2017-1-15|2017-1-15 Geek官网第二次讨论
- Vue.js|Mint-UI 移动首页开发 - header导航、banner轮播图
- uni-app开发(三)(项目实战之仿糗百首页)
- 首页展示之轮播图
- mui实现APP的一个首页面
- CSS导航菜单(仿淘宝首页导航条布局效果)
- 【系】微信小程序云开发实战坚果商城-前端之首页实现
- HTML|HTML 用Table布局商城首页