仿作经验
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];
// 视图显示
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];
}
}