根据font的大小 和string来 动态 获取label的长度
来源:互联网 发布:java怎么调用数组 编辑:程序博客网 时间:2024/06/07 04:51
CGSize wordSize = [@“要判断的字符串” sizeWithFont:allBtn.titleLabel.font];
根据数据动态添加label
if (self.originNamePrams) {
CGFloat originX = 20;
for (int i = 0; i < self.originNamePrams.count; i++) {
UIButton *tempBtn = [UIButton buttonWithType:UIButtonTypeCustom];
tempBtn.tag = i;
tempBtn.titleLabel.font = tempFont;
tempBtn.backgroundColor = [UIColor clearColor];
CGSize wordSize = [[[self.originNamePrams objectAtIndex:i] pramValue] sizeWithFont:tempBtn.titleLabel.font];
tempBtn.frame = CGRectMake(originX, 5, wordSize.width > 25 ? wordSize.width + 20 : 45, 25);
[tempBtn setTitle:[[self.originNamePrams objectAtIndex:i] pramValue] forState:UIControlStateNormal];
[tempBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[tempBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[tempBtn setBackgroundImage:[UIImage imageNamed:@"vod_screen_btn_selected"] forState:UIControlStateSelected];
[tempBtn addTarget:self action:@selector(whenSortOriginNameBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.sortOriginScrollView addSubview:tempBtn];
originX += tempBtn.bounds.size.width;
if (i == 0) {
[tempBtn setSelected:YES];
}
}
- 根据font的大小 和string来 动态 获取label的长度
- iOS根据文本长度动态计算label的大小
- 根据指定的图像路径和大小来获取缩略图
- 根据字体和文字来计算 UILable 的长度和大小
- ios 根据label文字大小,长度确定label的width和height
- 动态的获取label文本的宽度和高度,来判断是不是需要折行显示
- iOS--根据文本内容的长度动态改变label的宽度(有最大值)
- 根据label中的文本确定label的大小
- 根据图片路径来获取图片的真实大小
- 获取string的长度
- 根据字的大小自适应Label的大小
- [Android]根据名称name来获取string的值
- 根据Label的文字内容动态计算Label高度
- iOS-根据文本的长度确定label的宽高
- iOS7.0后 根据字符串长度计算label的尺寸
- iOS8.0 根据字符串长度计算label的尺寸
- iOS中如何动态获取label的宽度和高度
- 根据字体的长度来调节字体大小
- CSS Reset
- C#如何控制方法的执行时间,超时则强制退出方法执行
- CentOS比较好的第三方软件源
- android.os.PowerManager api运用
- Android EditText设置imeOptions没有效果的解决方法
- 根据font的大小 和string来 动态 获取label的长度
- Silverlight中打印文件
- HUNNU11351:Pythagoras's Revenge
- Machine Schedule (二分匹配)
- HDU 4631 Sad Love Story
- android_IntentService,AsyncTask,Handler
- http://www.csdn.net/articlehttp://www.csdn.net/article/2013-08-29/2816749-Non-Programming-game-tools
- MKMapView小结
- 项目估算-非编码任务的工作产品规模估算