gpt4 book ai didi

ios - 如何实现标签

转载 作者:行者123 更新时间:2023-11-29 03:23:39 25 4
gpt4 key购买 nike

我正在开发一个应用程序,我需要在其中显示每个讨论和每个评论的标签,如下图所示。我从这样的服务中获取标签。

tags =             (
Registration,
Apps,
PublicSpeaking,
Marketing,
Sales
);

我希望这些标签显示在给定图像的“标签”部分下。

enter image description here

这就是我尝试实现的方式,任何类型的教程或链接都会非常有帮助。

for (int i=0; i< [self.menuListArray count]; i++) {
NSString *tag_string = [self.menuListArray objectAtIndex:i];
CGSize tagSize = [tag_string sizeWithFont:[UIFont fontWithName:@"Roboto-Light" size:13.0]
constrainedToSize:CGSizeMake(230, FLT_MAX)
lineBreakMode:UILineBreakModeTailTruncation];
UIImageView *tag_bgimage = [[UIImageView alloc]init];
[tag_bgimage setFrame:CGRectMake(i*tagSize.width+5, stringSize.height+5, tagSize.width+4, 25)];
[tag_bgimage setBackgroundColor:[UIColor grayColor]];
[tag_bgimage setUserInteractionEnabled:NO];

UILabel *tagLabel = [[UILabel alloc]init];
[tagLabel setFrame:CGRectMake(0, 0, tagSize.width, 25)];
[tagLabel setBackgroundColor:[UIColor clearColor]];
[tagLabel setText:tag_string];
[tagLabel setFont:[UIFont fontWithName:@"Roboto-Light" size:12.0]];
[tagLabel setTextAlignment:NSTextAlignmentCenter];

[tag_bgimage addSubview:tagLabel];
[cell addSubview:tag_bgimage];

最佳答案

您可以使用 this Controller 。看起来像这样:

enter image description here

关于ios - 如何实现标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20761110/

25 4 0