相关疑难解决方法(0)

单个UILabel中的粗体和非粗体文字?

如何在uiLabel中包含粗体和非粗体文本?

我宁愿不使用UIWebView ..我也读过这可能是使用NSAttributedString,但我不知道如何使用它.有任何想法吗?

Apple在他们的几个应用程序中实现了这一点; 示例截图:链接文字

谢谢! - Dom

objective-c nsattributedstring uilabel ios swift

244
推荐指数
11
解决办法
15万
查看次数

使用NSAttributedString为UILabel设置突出显示的文本颜色.

我在tableview单元格上使用标签.已为单元格分配了一个属性字符串,但问题是在选择时,单元格文本对于属性字符串不会变为白色.

有没有办法解决它..?

任何帮助表示赞赏.

这是我的代码.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    LHSearchViewCell *cell = [LHSearchViewCell cellForTableView:tableView fromNib:_cellNib];

    cell.selectionStyle = UITableViewCellSelectionStyleGray;

    cell.headerLabel.textColor = [UIColor darkGrayColor];
    cell.headerLabel.highlightedTextColor = [UIColor whiteColor];
    cell.headerLabel.font = [UIFont systemFontOfSize:14];

    cell.subLabel.font = [UIFont systemFontOfSize:12];
    cell.subLabel.textColor = [UIColor darkGrayColor];
    cell.subLabel.numberOfLines = 2;
    switch (indexPath.section) {
        case 0:
        {
            UIFont *font = [UIFont systemFontOfSize:14.0];
            NSDictionary *firstAttributes = [NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,[UIColor darkGrayColor],NSForegroundColorAttributeName,nil];
            UIFont *secondFont = [UIFont systemFontOfSize:10.0];
            NSDictionary *secondAttributes = [NSDictionary dictionaryWithObjectsAndKeys:secondFont,NSFontAttributeName,[UIColor lightGrayColor],NSForegroundColorAttributeName,nil];
            NSString* completeString = [NSString …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsattributedstring ios

5
推荐指数
2
解决办法
1万
查看次数

UILabel有不同的字体

我有这个字符串,我想在标签中显示:

 NSString *criticsScore=[NSString stringWithFormat:@"%@\%%",[dict objectForKey:@"critics_score"]];

 _criticRating.text=criticsScore;
Run Code Online (Sandbox Code Playgroud)

我想设置一个小字体\%%和一个大字体[dict objectForKey:@"critics_score"]];
这是否可能?

objective-c ios

0
推荐指数
1
解决办法
5211
查看次数

标签 统计

ios ×3

objective-c ×3

nsattributedstring ×2

iphone ×1

swift ×1

uilabel ×1