我正在尝试用弯曲半径创建一个带有气泡的文本,如下图所示。
task = task;
member_date = member_date;
comments =comments;
activity = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@ %@", [task capitalizedString] , member_date , comments]];
[activity addAttributes:@{
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:14],
NSForegroundColorAttributeName: [UIColor blackColor],
}
range:NSMakeRange(0, task.length)];
[activity addAttributes:@{
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:14],
NSForegroundColorAttributeName: [UIColor colorWithRed:102.0f/255.0f green:102.0/255.0f blue:102.0/255.0f alpha:1],
}
range:NSMakeRange(task.length + 1, member_date.length)];
[activity addAttributes:@{
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:14],
NSForegroundColorAttributeName:[UIColor colorWithRed:102.0f/255.0f green:102.0/255.0f blue:102.0/255.0f alpha:1],
}
range:NSMakeRange(activity.string.length - comments.length, comments.length)];
return activity;
答案 0 :(得分:3)
这是我用以下代码实现的
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, 120, 30)];
[self.view addSubview:lbl];
[lbl setTextAlignment:NSTextAlignmentCenter];
[lbl setText:@"3 Comments"];
[lbl.layer setBorderColor:[[UIColor grayColor] CGColor]];
[lbl.layer setBorderWidth:1.5];
[lbl.layer setCornerRadius:15];
我得出
希望我收到你的要求