美文网首页
首页--HomePageCourseTableViewCell

首页--HomePageCourseTableViewCell

作者: 云兮77 | 来源:发表于2018-01-31 14:13 被阅读0次

    #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

          本文链接:https://www.haomeiwen.com/subject/yxnkzxtx.html