Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS文本标签状气泡_Ios_Nsattributedstring - Fatal编程技术网

iOS文本标签状气泡

iOS文本标签状气泡,ios,nsattributedstring,Ios,Nsattributedstring,我正试图创建一个气泡出来的文字弯曲半径如下图所示 task = task; member_date = member_date; comments =comments; activity = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@ %@", [task capitalizedString] , member_date , comments]]

我正试图创建一个气泡出来的文字弯曲半径如下图所示

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;


这是我用以下代码实现的

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];
然后我就出去了


希望我收到了你的要求

我只需要得到椭圆形的评论部分。任务文本周围不会有这个。只将层添加到必要的文本IDNT get u。你能详细说明一下吗?你的视图中可能有n个标签,因为你只想为注释添加气泡角,只为注释添加图层