首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS WatchOS5 --如何在手表应用程序中支持多个复杂家庭?

iOS WatchOS5 --如何在手表应用程序中支持多个复杂家庭?
EN

Stack Overflow用户
提问于 2019-02-25 22:44:59
回答 1查看 568关注 0票数 0

我有一个复杂的工作,我的苹果手表应用程序,我想增加第二种风格。我提出了一个非常基本的原型,但没有看到它可供选择的手表表面。所以我试着解决这个问题:

我的应用程序能支持不止一个并发症吗?,我可以在手表上同时运行两个并发症吗?(或者是这样,如果我有一个,iOS就不会显示第二个并发症?)我试着增加一个新的表脸,但它不允许我。

CLKComplicationTemplateModularSmallRingText ModularSmall 类型并发症的有效模板吗?

代码语言:javascript
复制
    func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {

        if complication.family == .modularSmall {
            let template = CLKComplicationTemplateModularSmallRingText()
            template.ringStyle = .open
            template.fillFraction = 0.3

            let testProvider = CLKSimpleTextProvider(text: "TST", shortText: "S")
            sleep.tintColor = UIColor.green
            template.textProvider = testProvider
            template.tintColor = UIColor.green

            let entry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)

            // Pass the entry to ClockKit.
            handler(entry)
        }
        else if complication.family == .graphicRectangular {
            let template = CLKComplicationTemplateGraphicRectangularLargeImage()
//this complication works...
}

占位符模板目前是相同的:

代码语言:javascript
复制
func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {

    // Pass the template to ClockKit.
    if complication.family == .modularSmall {
        let template = CLKComplicationTemplateModularSmallRingText()
//...

我在复杂的占位符文件中看到了一个错误(但我正在一个44毫米的设备上进行测试)--将修复它并查看发生了什么。我是返回一个错误的图像或错误的模板类型的模块复杂性?我想要一个圆环规

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-25 23:35:02

结果发现我被苹果的文件误导了。我需要使用GraphicCircular合并症(在WatchOS5中是新的)类型,而不是模块化(旧表脸)。

代码语言:javascript
复制
func circularTemplate() -> CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText{
    let template = CLKComplicationTemplateGraphicCircularOpenGaugeSimpleText()
    let gauge = CLKSimpleGaugeProvider(style: .ring, gaugeColor: UIColor.green), fillFraction: 0.3)
    template.gaugeProvider = gauge

    let random = arc4random() % 999

    let middle = CLKSimpleTextProvider(text: "4.5", shortText: "4")
    middle.tintColor = kRGBColorFromHex(0x657585)
    template.tintColor = kRGBColorFromHex(0x657585)
    template.centerTextProvider = middle

    let bottom = CLKSimpleTextProvider(text: "-\(random)", shortText: "1..")
    template.bottomTextProvider = bottom
    return template
}

新款式:

旧式:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54875838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档