带属性的 Monotouch 自定义字体
如何在单触摸中指定字体粗体/斜体等属性?
实际上可以在本机库中实现 http://www.freetimestudios。 com/2010/09/20/ipad-and-ios-4-custom-font-loading/
NSDictionary *fontAttributes =
[NSDictionary dictionaryWithObjectsAndKeys:
@"Courier", (NSString *)kCTFontFamilyNameAttribute,
@"Bold", (NSString *)kCTFontStyleNameAttribute,
[NSNumber numberWithFloat:16.f], (NSString *)kCTFontSizeAttribute,
nil];
CTFontDescriptorRef descriptor =
CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes);
CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, 0, NULL);
CFRelease(descriptor);
How can i specify font bold/italic etc. properties in monotouch?
Actually possible in native library
http://www.freetimestudios.com/2010/09/20/ipad-and-ios-4-custom-font-loading/
NSDictionary *fontAttributes =
[NSDictionary dictionaryWithObjectsAndKeys:
@"Courier", (NSString *)kCTFontFamilyNameAttribute,
@"Bold", (NSString *)kCTFontStyleNameAttribute,
[NSNumber numberWithFloat:16.f], (NSString *)kCTFontSizeAttribute,
nil];
CTFontDescriptorRef descriptor =
CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes);
CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, 0, NULL);
CFRelease(descriptor);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与您的代码片段匹配的 MonoTouch / C# 代码如下所示:
The MonoTouch / C# code to match your code snippet would look like this: