【发布时间】:2018-01-16 17:26:58
【问题描述】:
我的 Xamarin Forms 应用程序设计师为标签字段指定了 Small Caps。在 Xamarin for Android 中有几个关于如何执行此操作的讨论,但我找不到任何适用于 iOS 的内容。
我知道我需要一个自定义渲染器,并且在 here 上找到了很好的讨论,但在将那篇文章中的 Swift 代码转换为 Xamarin iOS 的 C# 时遇到了挑战。
代码如下:
let systemFont = UIFont.systemFont(ofSize: 24.0, weight: UIFontWeightLight)
let smallCapsDesc = systemFont.fontDescriptor.addingAttributes([
UIFontDescriptorFeatureSettingsAttribute: [
[
UIFontFeatureTypeIdentifierKey: kUpperCaseType,
UIFontFeatureSelectorIdentifierKey: kUpperCaseSmallCapsSelector
]
]
])
let font = UIFont(descriptor: smallCapsDesc, size: systemFont.pointSize)
我知道我会在我的 OnElementChanged 方法中添加一些东西,但是 FontDescriptor 没有添加属性方法或属性集合,因此在添加其他属性时遇到了挑战。
【问题讨论】:
标签: ios xamarin custom-renderer