#import "ViewController.h"
@interface SpecialLabel:UILabel
@end @implementation SpecialLabel - (CGSize)sizeThatFits:(CGSize)size { CGSize s = [super sizeThatFits:size]; return CGSizeMake(s.width +, s.height +);
}
@end @interface ViewController () @property (weak, nonatomic) IBOutlet SpecialLabel *label; @end @implementation ViewController - (IBAction)changeText { self.label.text = @"fsdgdssssssssssss ";
#if 1
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.label sizeToFit];
}];
#else
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.label sizeToFit];
});
#endif }
直接这样写不知道为什么不行
self.label.text = @"fsdgdssssssssssss ";
[self.label sizeToFit];
非得搞个
[NSOperationQueue mainQueue]或者延时,记录一下