4399 仿作经验

仿作经验

1) 展开拉起  全局变量 控制高度

        //摘要内容

        self.abructView = [[UIWebViewalloc]initWithFrame:CGRectMake(self.abructlabel.frame.origin.x,self.abructlabel.frame.origin.y +self.abructlabel.frame.size.height ,self.view.bounds.size.width,130 - 4)];

        // 全局变量的高度

       self.abractheight =130;

        self.abructView.scrollView.scrollEnabled =NO;

        [self.abructViewloadHTMLString: [[self.abractArrlastObject]detail_abstract ]baseURL:nil];

        [self.whiteviewfouraddSubview:self.abructView];

        [_abructViewrelease];

        

        self.abtactbutton = [UIButtonbuttonWithType:UIButtonTypeCustom];

        [self.abtactbuttonsetTitle:@"展开"forState:UIControlStateNormal];

        self.abtactbutton.frame =CGRectMake(self.abructView.frame.origin.x + 280, self.abructView.frame.origin.y +self.abructView.frame.size.height,40,20);

        self.abtactbutton.backgroundColor = [WebColorblueViolet];

        [self.abtactbuttonaddTarget:selfaction:@selector(zhanButtonClick:)forControlEvents:UIControlEventTouchUpInside];

        [self.whiteviewfouraddSubview:self.abtactbutton];


2) 根据接口判断数据 控件是否存在

// 视图显示

        self.segmentbuttonview = [[UIViewalloc]initWithFrame:CGRectMake(self.view.bounds.origin.x,60,self.view.bounds.size.width,20)];

        self.segmentbuttonview.backgroundColor = [UIColorwhiteColor];

        [self.whiteviewfouraddSubview:self.segmentbuttonview];

        [_segmentbuttonviewrelease];

        // 判断button的个数

       //名字

       self.buttoncount =1;

       //游戏视频

       if ([self.stratearrcount] !=0) {

           self.buttoncount++;

           self.strateg =1;

        }

       if ([self.videoarrcount] !=0) {

           self.buttoncount++;

           self.video =1;

        }

        // 没有攻略和视频

       if (self.buttoncount ==1) {

            self.segmentbuttonview.backgroundColor = [UIColorclearColor];

           self.heightone =YES;

        }else {

           self.heightone =YES;

           //有三个

           if (self.buttoncount ==3) {

               //创建分段控制器

               NSMutableArray *namearr = [NSMutableArrayarrayWithObjects:@"游戏简介",@"游戏攻略",@"精彩视频",nil];

                self.namesegmentcontroller = [[UISegmentedControlalloc]initWithItems:namearr];

                self.namesegmentcontroller.frame =CGRectMake(10,0,300,20);

                self.namesegmentcontroller.tintColor = [UIColorcyanColor];

                self.namesegmentcontroller.selectedSegmentIndex =0;

                [self.namesegmentcontrolleraddTarget:selfaction:@selector(buttonSelected:)forControlEvents:UIControlEventValueChanged];

                [self.segmentbuttonviewaddSubview:self.namesegmentcontroller];

                [_namesegmentcontrollerrelease];

               self.video =1;

               self.strateg =1;

                

            }elseif(self.buttoncount ==2 &&self.strateg ==1) {

               //有游戏攻略

               NSMutableArray *namearr = [NSMutableArrayarrayWithObjects:@"游戏简介",@"游戏攻略",nil];

                self.namesegmentcontroller = [[UISegmentedControlalloc]initWithItems:namearr];

                self.namesegmentcontroller.frame =CGRectMake(10,0,300,20);

                self.namesegmentcontroller.tintColor = [UIColorcyanColor];

                self.namesegmentcontroller.selectedSegmentIndex =0;

                [self.namesegmentcontrolleraddTarget:selfaction:@selector(buttonSelected:)forControlEvents:UIControlEventValueChanged];

                [self.segmentbuttonviewaddSubview:self.namesegmentcontroller];

                [_namesegmentcontrollerrelease];


                

            }elseif(self.buttoncount ==2 &&self.video ==1){

               //精彩视频

               NSMutableArray *namearr = [NSMutableArrayarrayWithObjects:@"游戏简介",@"精彩视频",nil];

                self.namesegmentcontroller = [[UISegmentedControlalloc]initWithItems:namearr];

                self.namesegmentcontroller.frame =CGRectMake(10,0,300,20);

                self.namesegmentcontroller.tintColor = [UIColorcyanColor];

                self.namesegmentcontroller.selectedSegmentIndex =0;

                [self.namesegmentcontrolleraddTarget:selfaction:@selector(buttonSelected:)forControlEvents:UIControlEventValueChanged];

                [self.segmentbuttonviewaddSubview:self.namesegmentcontroller];

                [_namesegmentcontrollerrelease];

                

            }

        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值