私は uilabel の後ろに画像を配置しようとしていて、両方がほぼ同じ高さである必要があります (uilabel を囲むために uiimageview は少し大きい)、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];