How to highlight only text in UILabel - IOS

后端 未结 4 1650
轻奢々
轻奢々 2020-12-14 22:57

I just want to highlight only text in UILabel, I have tried by giving backgroundColor for label, but it is highlighting the empty spaces also looks

4条回答
  •  太阳男子
    2020-12-14 23:44

    try this

    MTLabel

        MTLabel *label4 = [MTLabel labelWithFrame:CGRectMake(20, 270, 250, 60) 
                                      andText:@"This label is highlighted, has a custom line height, and adjusts font size to fit inside the label."];
            [label4 setLineHeight:22];
            [label4 setFont:[UIFont fontWithName:@"Helvetica" size:30]];
            [label4 setAdjustSizeToFit:YES];
            [label4 setMinimumFontSize:15];
            [label4 setFontHighlightColor:[[UIColor orangeColor] colorWithAlphaComponent:0.5]];
            [self.view addSubview:label4];
    

提交回复
热议问题