1条回答
- gaoXxxing 2013-05-07 06:02关注
用这段代码可以给text后面添加子视图:
CGSize size= [[label text] sizeWithFont:[UIFont systemFontOfSize:18.0]]; NSLog(@"%.1f | %.1f", size.width, size.height); NSLog(@"%.1f | %.1f", label.frame.size.width, label.frame.size.height); UIView *highlightView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)]; [highlightView setBackgroundColor:[UIColor greenColor]]; [self.view insertSubview:highlightView belowSubview:label]; [highlightView setCenter:label.center]; And don't forget: [label setBackgroundColor:[UIColor clearColor]];
解决 无用评论 打赏 举报