我试图将图像放在 uilabel 后面,并且两者都需要大约相同的高度(uiimageview 比 uilabel 大一点)并且我在 cgrectmake 中给出了相同的高度,但是 uiimageview 仍然比 uilabel 小,即使它们设置为相同的高度。请帮助!代码:
UILabel *labelEntry = [[UILabel alloc]init];
labelEntry.numberOfLines = 0;
labelEntry.text = entry;
CGSize expectedLabelSize = [entry sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:CGSizeMake(300.f, FLT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
CGRect lblFrame = CGRectMake(13, 30, 320, expectedLabelSize.height);
labelEntry.frame = lblFrame;
labelEntry.lineBreakMode = NSLineBreakByWordWrapping;
labelEntry.font = [UIFont systemFontOfSize: 17.0];
labelEntry.textAlignment = NSTextAlignmentCenter;
labelEntry.backgroundColor = [UIColor clearColor];
UIImageView *backgroundImage = [[UIImageView alloc]initWithFrame:CGRectMake(13, 30, 320, expectedLabelSize.height)];
backgroundImage.image = [UIImage imageNamed:@"postl.png"];
[scrollView addSubview:backgroundImage];