Closed yangdehui closed 4 years ago
alert.attributedFormatBlock = ^NSAttributedString (NSString value) { NSMutableAttributedString *subTitle = [[NSMutableAttributedString alloc]initWithString:value]; NSRange redRange = [value rangeOfString:currentModel.name options:NSCaseInsensitiveSearch]; [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; return subTitle; }; 测试发现代码中 textview.attributedText赋值后需重新设置一下textview.textAlignment属性,而您只在初始化做了设置。
English, please and describe your issue
alert.attributedFormatBlock = ^NSAttributedString (NSString value) { NSMutableAttributedString *subTitle = [[NSMutableAttributedString alloc]initWithString:value]; NSRange redRange = [value rangeOfString:currentModel.name options:NSCaseInsensitiveSearch]; [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; return subTitle; }; 测试发现代码中 textview.attributedText赋值后需重新设置一下textview.textAlignment属性,而您只在初始化做了设置。