发现 button设置背景图片 iOS7 与 iOS8 差异
来源:互联网 发布:himall2.4完整版源码 编辑:程序博客网 时间:2024/04/30 13:06
有待详细研究
iOS7: 只能显示 .titleLabel.textColor
<span style="color:#ff0000;">self.btnNum.titleLabel.textColor=[UIColor blueColor];</span>
iOS8: 只能显示 setTitleColor
<span style="color:#3366ff;">[self.btnNum setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];</span>
问题还未找到原由!有待观察。。。
代码如下:
//复用机制
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString * cellName=@"cell"; HYHistoryCell * historyCell=[_tableViewHistory dequeueReusableCellWithIdentifier:cellName]; if (historyCell==nil){ historyCell=[[HYHistoryCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName]; historyCell.selectionStyle = UITableViewCellSelectionStyleNone; } NSDictionary * dic = [_arrRecord objectAtIndex:indexPath.row]; /* * 期数 */ historyCell.labelIssue.text=[NSString stringWithFormat:@"第%@期",dic[@"issueNum"]]; /* * nums */ historyCell.arrayNum=dic[@"result"]; historyCell.boundaryNum = _boundaryNum; [historyCell createButtons]; return historyCell;}
//自定义cell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self){ // Initialization code self.labelIssue=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 30)]; self.labelIssue.text=@"期数"; self.labelIssue.textColor=[UIColor blackColor]; // self.labelIssue.backgroundColor=[UIColor grayColor]; self.labelIssue.font=[UIFont systemFontOfSize:15.f]; [self.contentView addSubview:self.labelIssue]; self.arrayBtn = [[NSMutableArray alloc] init]; } return self;}-(void)createButtons{ //移除之前赋值的btn for (UIButton *button in self.arrayBtn) { [button removeFromSuperview]; } [self.arrayBtn removeAllObjects]; if ([self.arrayNum count]>0) { for (int i=0; i<[self.arrayNum count]; i++) { self.btnNum=[UIButton buttonWithType:UIButtonTypeCustom]; self.btnNum.enabled=NO; self.btnNum.frame=CGRectMake(10+i*(BTNHEIGHT+2), 30, BTNWIDTH, BTNHEIGHT); [self.btnNum setBackgroundImage:[UIImage imageNamed:@"small_circle_light"] forState:UIControlStateNormal]; [self.btnNum setTitle:[NSString stringWithFormat:@"%.2d",[[self.arrayNum objectAtIndex:i] intValue]] forState:UIControlStateNormal]; //根据界面判断字体模式 if ([_boundaryNum intValue] == 1) { <span style="color:#ff0000;">self.btnNum.titleLabel.textColor=[UIColor blueColor];</span> <span style="color:#3366ff;">[self.btnNum setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];</span> if ([[self.arrayNum objectAtIndex:i] integerValue] == 19||[[self.arrayNum objectAtIndex:i] integerValue] == 20) { <span style="color:#3366ff;">[self.btnNum setTitleColor:[UIColor redColor] forState:UIControlStateNormal];</span> <span style="color:#ff0000;">self.btnNum.titleLabel.textColor=[UIColor redColor];</span> } } else if([_boundaryNum intValue] == 2){ if (i < 6) { [self.btnNum setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; } else{ [self.btnNum setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; } } else if([_boundaryNum intValue] == 3){ [self.btnNum setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; } [self.contentView addSubview:self.btnNum]; [self.arrayBtn addObject:self.btnNum]; } } }
0 0
- 发现 button设置背景图片 iOS7 与 iOS8 差异
- iOS7 与 iOS8上 uisegementcontrol 设置image不显示问题
- iOS7 与 iOS8上 uisegementcontrol 设置image不显示问题
- iOS7与iOS8的比较
- UIButton, 设置button的背景图片
- button设置点击更改背景图片
- iOS7设置圆角Button
- iOS8与iOS7适配问题
- iOS8与iOS7图片异常及解释
- ios8 CLLOcationManager 定位与ios7的对比
- ios7与ios8并存,注册推送通知
- ios8与ios7有什么区别
- android中自定义Button,设置不同背景图片。
- 点击Button选择切换背景图片设置
- java中button背景图片大小设置,JFrame.getContentPane().add(pane)与JFrame.add(pane)区别
- 为button设置背景图片,且全无button痕迹的css
- QTextEdit 设置背景图片与拉伸背景图片
- IOS7下的UITabBarItem 的背景图片的设置
- 委托机制在线程中的使用的简单实例
- 人生就是这样
- SAP 已经Release(释放)的传输请求(TR)重新传输-SE03
- 网络游戏特有的要素之二带宽
- Linux下画原理图和PCB
- 发现 button设置背景图片 iOS7 与 iOS8 差异
- Eclipse中安装MAVEN插件
- 深入java--注解
- oracle 并行操作
- ReportStudio进阶教程(三十二) - 地图开发(六)修改Cognos地图文件
- 去鱼尾纹的最好方法 美在“睛”细之处,做个花样女人
- Projection Matrix and Linear Regression
- B. OR in Matrix
- 2014-12-15记录