这是创建文本的代码,我试图设置颜色:
//// Rounded Rectangle Drawing UIBezIErPath* roundedRectanglePath = [UIBezIErPath bezIErPathWithRoundedRect: CGRectMake(0,66,66) cornerRadius: 15]; [[NPScolor NPSPrimarycolor] setFill]; [roundedRectanglePath fill]; UIFont *helveticaFont = [UIFont FontWithname:@"AvenirNextCondensed-Bold" size:50]; NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutablecopy]; /// Set line break mode paragraphStyle.lineBreakMode = NSlineBreakByWorDWrapPing; /// Set text alignment paragraphStyle.alignment = NSTextAlignmentCenter; NSDictionary *attributes = @{NSFontAttributename:helveticaFont,NSParagraphStyleAttributename:paragraphStyle}; //// Text Drawing CGRect textRect = CGRectMake(-4,-2.5,74,71.5); [[NPScolor whitecolor] set]; [textContent drawInRect: CGRectInset(textRect,6) withAttributes:attributes];}
“文本绘图”中的白色是不能正常工作的.谢谢你的帮助.
@H_403_8@@R_419_6120@ 您需要通过以下方式设置传入的“属性”字典中文本的颜色:[textContent drawInRect: CGRectInset(textRect,6) withAttributes:attributes];
我的建议是:
NSDictionary *attributes = @{ NSFontAttributename:helveticaFont,NSParagraphStyleAttributename:paragraphStyle,NSForegroundcolorAttributename: [NPScolor whitecolor]}@H_403_8@ @H_403_8@ 总结
以上是内存溢出为你收集整理的ios – 使用drawInRect时如何设置文本颜色?全部内容,希望文章能够帮你解决ios – 使用drawInRect时如何设置文本颜色?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)