jjzjj

NSForegroundColorAttributeName

全部标签

ios - 是否可以从嵌入式 UITableViewController 设置父 UITabViewController 属性

当涉及到嵌入式View时,我有点困惑。我在Storyboard中创建了以下结构:-UITabBarViewController-UINavigationViewController-UITableViewController(MyTableViewController)那么对于我的问题,是否可以从我的自定义UITableViewController(MyTableViewController)中设置选项卡栏项目属性,例如标题字体?我在MyTableViewController中尝试了以下代码:-(void)viewDidLoad{[superviewDidLoad];//Settabb

ios - 解析 ANSI 颜色代码并为 NSAttributedString 设置相应的颜色属性

我需要一种方法来解析shell输出中的ANSI颜色代码,以便为NSAttributedString设置相应的颜色属性。输入字符串类似于:[0;31m这应该是红色的。[0;34m这应该是蓝色的。[0;32m这应该是绿色的。[0;31m这也应该是红色的。在我从输出中删除Ansi代码后,我的代码以某种方式与颜色不匹配。我当前的代码如下:-(NSAttributedString*)ansicodeParser:(NSString*)str{//initstringNSMutableString*mutableStr=[[NSMutableStringalloc]initWithString:s

ios - 在 iOS 7 中使用系统字体时,NSAttributedString 双 "ff"计为单个 "f"

我发现在iOS7中使用“ff”字符串时系统字体的NSAttributedString有一个奇怪的行为。它被视为单个字母。这是要测试的结果和代码。它是错误还是功能?如何在不更改字体的情况下摆脱它?如果我将字体更改为其他字体,字母的颜色会正确显示。@property(nonatomic)IBOutletUILabel*testText-(void)testALetter{NSDictionary*blackText=@{NSForegroundColorAttributeName:[UIColorblackColor],NSFontAttributeName:[UIFontsystemFo

ios - NSForegroundColorAttributeName 未声明

当使用下面的代码片段时,我在上得到了undefined/undeclarederrorNSForegroundColorAttributeNameThisistheurlireferred我的代码片段NSMutableAttributedString*string=[[NSMutableAttributedStringalloc]initWithString:self.myDisplayTxt];[stringaddAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor]range:NSMakeRange(0,5)]

iphone - NSMutableAttributedString - NSForegroundColorAttributeName

我正在尝试设置数组中所有范围的颜色,但出现此错误。我不明白为什么。范围都有效。我什至尝试手动插入一个范围来测试它。谢谢。CGContextSetFillColorWithColor:无效上下文0x0NSMutableAttributedString*string=[[NSMutableAttributedStringalloc]initWithString:tv.text];for(NSString*sinarray){[stringaddAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor]range:NSRan

ios - 在属性字符串上设置 NSForegroundColorAttributeName 会在 iOS 6 上向下移动文本

我在我的iOS应用程序中使用属性字符串来为文本提供一些样式:NSDictionary*titleAttributes=@{NSFontAttributeName:[UIFontfontWithName:@"Raleway"size:12],NSForegroundColorAttributeName:[UIColorlightGreyTextColor]};NSMutableAttributedString*attributedTitle=[[NSMutableAttributedStringalloc]initWithString:titleattributes:titleAttri

ios - 更改字形中单个字符的颜色

据我了解,字符串包含字形,而字形可能由单个字符组成。对我来说这是个问题,因为我想更改字符串中某些变音符号的颜色。假设我们有以下字符串:วาีม对于这个字符串,我想让辅音的颜色不同,因为它是变音符号。即:我想为วาม和ี使用不同的颜色。从我的测试来看,我似乎只能为单个字形着色。看来我无法在字符(变音符号)级别更改颜色。一些示例代码:lettext=NSMutableAttributedString(string:"วาีม")text.addAttribute(NSForegroundColorAttributeName,value:UIColor.blue,range:NSMakeRa

ios - 带有 UITextField 的属性文本

我正在尝试将属性文本与UITextField一起使用。我已自定义占位符文本,但它忽略了我为主文本属性设置的值。nameTextField.attributedText=NSAttributedString(string:"",attributes:[NSForegroundColorAttributeName:UIColor.white,NSParagraphStyleAttributeName:paraStyle,NSFontAttributeName:UIFont.init(name:"HelveticaNeue-Bold",size:16)]);奇怪的是,Storyboard中也

ios - 在 iOS 的 Swift 中将 TabBarItem 标题字体更改为粗体

我正在尝试将所选标签栏项目的字体粗细设置为粗体。好像没有效果。知道什么是错的。forState:.Normal按预期工作,forState:.Selected无效。lettabBarItem0=tabBar.items![0]as!UITabBarItemvarselectedImage0:UIImage=UIImage(named:"ic_tabbar_item_one")!.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)varfontLight:UIFont=UIFont(name:"HelveticaNeue

ios - 更改 iOS 中禁用的条形按钮项目的颜色

我需要在导航栏中显示我的应用程序图标。为此,我将其添加为右栏按钮项。我不希望它是可点击的,我只需要那里的图标,所以我将其设置为禁用。问题是图标显示为灰色,而不是绿色。有没有办法禁用此按钮,同时保持其原始颜色? 最佳答案 试试这个:letbarButtonItem=UIBarButtonItem(title:"Click",style:.Done,target:self,action:#selector(didClick(_:)))barButtonItem.setTitleTextAttributes([NSForegroundCo