How can I change the frame of a textLabel cell?

I tried almost everything, but I just can't move the cell.textLabel property a bit. I added a screenshot below and I tried almost everything I could find.

I tried to change the .frame property directly, tried to change if using the table tableView: (UITableView *) tableView: (UITableView *) tableView the "method" will be displayed. I also tried to highlight a custom label. move the custom label, but it will not appear on separate lines, such as the original textLabel. I just need to move the drawn multi-line label a bit.

Any help is appreciated!

enter image description here

+8
ios iphone uilabel
source share
4 answers

The only way to do this is to use a subclass of UITableViewCell and override -layoutSubviews . In this method, you want to call [super layoutSubviews] , and then execute whatever frame frames you want tagged.

+16
source share

override layoutSubviews for your UITableViewCell ...

 - (void)layoutSubviews { [super layoutSubviews]; CGSize size = self.bounds.size; CGRect frame = CGRectMake(4.0f, 4.0f, size.width, size.height); self.textLabel.frame = frame; self.textLabel.contentMode = UIViewContentModeScaleAspectFit; } 

or you can just create your own UILabel object and add it to cell.contentView as a preview.

 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(4, 4, 30, 30)]; [cell.contentView addSubview:label]; [label release]; 
+21
source share

I ended up adding \ n at the beginning of the line. Unfortunately, I could not get anything to work.

+1
source share
 - (void)layoutSubviews { [super layoutSubviews]; CGSize size = self.bounds.size; CGRect frame = CGRectMake(4.0f, 4.0f, size.width, size.height); self.textLabel.frame = frame; self.textLabel.textAlignment = NSTextAlignmentCenter; } 
0
source share

All Articles