开发者

How to change the size of the labels on a UITableViewCellStyleValue2 cell? (UITableView iPhone)

开发者 https://www.devze.com 2022-12-16 17:20 出处:网络
I\'m using a UITableViewCellStyleValue2 cell in my UITableView in my app and I want the left column (the blue text - self.textField) to be much narrower than 开发者_运维技巧the default.I\'ve tried set

I'm using a UITableViewCellStyleValue2 cell in my UITableView in my app and I want the left column (the blue text - self.textField) to be much narrower than 开发者_运维技巧the default. I've tried setting the self.textField.bounds after creating the cell but this doesn't seem to work - looking in the debugger it appears the bounds haven't been set.

Can I edit the default cell type in this way, or should I just make my own subclass of UITableViewCell?

Thanks.


You can subclass UITableViewCelland still use UITableViewCellStyleValue2. You can then overwrite the layoutSubviews method to change the size of the labels:

- (void) layoutSubviews {
   [super layoutSubviews]; // layouts the cell as UITableViewCellStyleValue2 would normally look like

   // change frame of one or more labels
   self.textLabel.frame = CGRectMake(...);
   self.detailTextLabel.frame = CGRectMake(...);    
}
0

精彩评论

暂无评论...
验证码 换一张
取 消