Iphone 标签之间的自动间距
如何设置标签之间的自动间距。动态文本被提供给标签,第二个标签应该自动设置框架,这样两个标签就不会被过度书写。我怎样才能做到这一点。我需要当第一个标签文本完成后,第二个标签开始与前一个标签保持距离。请为以上内容提供指导。Iphone 标签之间的自动间距,iphone,whitespace,Iphone,Whitespace,如何设置标签之间的自动间距。动态文本被提供给标签,第二个标签应该自动设置框架,这样两个标签就不会被过度书写。我怎样才能做到这一点。我需要当第一个标签文本完成后,第二个标签开始与前一个标签保持距离。请为以上内容提供指导。 提前感谢。使用constrainedToSize属性调整UILabel框架 CGRect infoRect = self.conditionLabel.frame; NSString *fileName = [[NSBundle mainBundle] pathForResour
提前感谢。使用
constrainedToSize
属性调整UILabel
框架
CGRect infoRect = self.conditionLabel.frame;
NSString *fileName = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"txt"];
NSString *textString = [[NSString alloc] initWithContentsOfFile:fileName encoding:NSUTF8StringEncoding error:nil];
[self.conditionLabel setText:textString];
[textString release];
CGSize defaultSize = CGSizeMake(sectionWidth, 9999.0);
UIFont *defaultFont = kCCOpenSansFont(font, 14.0);
CGSize infoSize = [[self.conditionLabel text] sizeWithFont:defaultFont constrainedToSize:defaultSize lineBreakMode:UILineBreakModeWordWrap];
infoRect.size.height = infoSize.height;
[self.conditionLabel setFrame:infoRect];
试试这个
CGSize size = [firstLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]];
secondLabel.frame=CGRectMake(size.width+20,4, 9, 14);
欲了解更多信息,请点击此链接
用于获取图像大小
UIImage *tempimage= [UIImage imageWithContentsOfFile:fullImgNm];
Float width = tempimage.size.width;
因此,您的imageview框架将
yourImageView.frame=CGRectMake(size.width+20,4,width, 14);
secondLabel.frame=CGRectMake(size.width+width+20,4, 9, 14);
您的第二个标签框将是
yourImageView.frame=CGRectMake(size.width+20,4,width, 14);
secondLabel.frame=CGRectMake(size.width+width+20,4, 9, 14);
我的imageview位于两个可调变量之间。您可以使用图像宽度设置imageview的宽度,即image.size.width我的imageview位于两个可调变量之间。是的,您可以。您可以调整frame CGRect IMAINSERT=imageview.frame:imageRect.origin.y=FIRSTLABLE.frame.origin.y+FIRSTLABLE.frame.size.height+5;imageview.frame=imageRect;