NSString *st = [NSString stringWithFormat:@"%lu \n", step];
NSString *currentSteps = [st stringByAppendingString:NSLocalizedString(@"steps", "")];
[_circleProgressBar setHintTextGenerationBlock:(^NSString *(CGFloat progress) {
return [NSString stringWithFormat:@"%@", currentSteps];
} )];
我现在有很多步骤,如下所示:
0
步骤
但是,如果0应该在字符串步骤的中心,那将是很好的。
答案 0 :(得分:0)
您可以使用带有文本中心的段落创建NSAttributedString
。
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.alignment = NSTextAlignmentCenter;
NSDictionary *attributes = @{ NSParagraphStyleAttributeName : paragraphStyle];
NSAttributedString *label = [[NSAttributedString alloc] initWithString:currentSteps attributes:attributes]