在 Iphone 应用程序中,有没有办法在标签文本中添加空格以创建空白空间(由大小指定)。这背后的想法是我想将第二个字符串附加到标签上,但以固定大小分隔。
像这样的东西:
//first we append a string containing only spaces to create a width of 100
label1.text = [label1.text stringByAppendingString:[self getSpaceStringByWidth:100 font:label1.font];
//then we append the second string
label1.text = [label1.text stringByAppendingString:@"something else to append"];
-(NSString*)getSpaceStringByWidth:(CGFloat)width andFont:(UIFont*)font
{
//This method takes the width needed and the font used and returns a string containing only empty spaces that will create an empty space before appending the second string
}