标签:
UILabel *left = [[UILabel alloc] init]; left.text = @" Sent when the application is about to move from active to inactive state."; left.backgroundColor = [UIColor blueColor]; //每个label宽200 UIFont *font = left.font; NSString *content = left.text; CGSize realSize = [content sizeWithFont:font constrainedToSize:CGSizeMake(200, 1000)]; left.frame = CGRectMake(10, 30, realSize.width, realSize.height); left.numberOfLines = 0; left.layer.cornerRadius = 10; left.clipsToBounds = YES; [self.window addSubview:left]; UILabel *right = [[UILabel alloc] init]; right.text = @"Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates"; right.backgroundColor = [UIColor redColor]; //计算高度,宽度200 font = right.font; content = right.text; realSize = [content sizeWithFont:font constrainedToSize:CGSizeMake(200, 1000)]; CGFloat leftMaxY = CGRectGetMaxY(left.frame); right.frame = CGRectMake(320 - realSize.width - 10, leftMaxY + 20, realSize.width, realSize.height); right.numberOfLines = 0; right.layer.cornerRadius = 10; right.clipsToBounds = YES; [self.window addSubview:right];
标签:
原文地址:http://www.cnblogs.com/wlsky/p/4502070.html