我有一个应用程序,我在标签后添加图像,标签是动态的。之后我需要添加一张图片UILabel
。我试过`
dropdownlabel = [[UILabel alloc]init];
[dropdownlabel setFrame:CGRectMake(90,8,180, 30)];
[dropdownlabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
dropdownlabel.textAlignment = UITextAlignmentLeft;
dropdownlabel.textColor = [UIColor whiteColor];
dropdownlabel.numberOfLines = 0;
dropdownlabel.text=@"gdhhgsfghdfagsfd ";
dropdownlabel.backgroundColor =[UIColor clearColor];
[navview addSubview:dropdownlabel];
CGSize maximumLabelSize = CGSizeMake(9999,30);
CGSize expectedLabelSize = [dropdownlabel.text sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]constrainedToSize:maximumLabelSize lineBreakMode:dropdownlabel.lineBreakMode];
//adjust the label the the new height.
CGRect newFrame = dropdownlabel.frame;
newFrame.size.height = expectedLabelSize.height;
dropdownlabel.frame = newFrame;
NSLog(@"%f",newFrame.size.width);
UIImageView *navview1=[[UIImageView alloc] initWithFrame:CGRectMake( newFrame.size.width+15,13,20,20)];
navview1.image = [UIImage imageNamed:@"down_sml_arrow.png"];
navview1.userInteractionEnabled=YES;
[navview addSubview:navview1];
但对一些人来说是正确的,但对另一些人来说是错误的。谁能指导我哪里出错了?