我有可用填充的问题。我想让我的 uilabel 有填充事件只有一个字符显示
http://i.stack.imgur.com/T4Aet.png
所以我有“问问题”字的填充,
我所做的是:
#import "NetraCell.h"
#import <QuartzCore/QuartzCore.h>
@implementation NetraCell
@synthesize NetraLabelForPrice,NetraImageDeals;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
/////implement for NetraLabelForPrice
//
NetraLabelForPrice=[[UILabel alloc] init];
NetraLabelForPrice.backgroundColor=[UIColor brownColor];
NetraLabelForPrice.textColor=[UIColor whiteColor];
NetraLabelForPrice.textAlignment=NSTextAlignmentCenter;
NetraLabelForPrice.font=[UIFont fontWithName:@"HelveticaNeue-Bold" size:18];
[NetraLabelForPrice.layer setCornerRadius:20];
// NetraImageDeals=[[UIImage alloc] init];
[self.contentView addSubview:NetraLabelForPrice];
/////
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)layoutSubviews {
[super layoutSubviews];
self.imageView.frame = CGRectMake(10.0f, 15.0f, 80.0f, 80.0f);
self.NetraLabelForPrice.frame = CGRectMake(100.0f, 15.0f, NetraLabelForPrice.frame.origin.x, 25);
[self.imageView.layer setCornerRadius:7.0f];
[self.NetraLabelForPrice.layer setCornerRadius:7.0f];
}
@end
我这样放
self.NetraLabelForPrice.frame = CGRectMake(100.0f, 15.0f, NetraLabelForPrice.frame.origin.x, 25);
但是为什么当我 label.text 只是“-”时宽度没有减小?