sizeToFit

直接log :

 

- (void)viewDidLoad

{

    [superviewDidLoad];

    UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 90, 90)];

    whiteView.backgroundColor = [UIColorwhiteColor];

    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 70, 20)];

    label.text = @"kkjkjkkjkjkjkjjkjkjkjjkjkkjkjkjkjk";

    [whiteView addSubview:label];

    

    NSLog(@"the label bounds : %@", NSStringFromCGRect(label.frame));

    [label sizeToFit];

    NSLog(@"the label bounds : %@", NSStringFromCGRect(label.frame));

    

    [self.view addSubview:whiteView];

}

 

 

2012-04-05 11:41:23.689 aaaa[2340:b903] the label frame : {{0, 0}, {70, 20}}

2012-04-05 11:41:23.690 aaaa[2340:b903] the label frame : {{0, 0}, {214, 21}}


ok, know 了

posted @ 2012-04-05 11:42  姜萌芽  阅读(360)  评论(0编辑  收藏  举报