`
啸笑天
  • 浏览: 3438418 次
  • 性别: Icon_minigender_1
  • 来自: China
社区版块
存档分类
最新评论

Complications on the watch face

 
阅读更多

 

watchOS2支持自定义表盘的Complication(苹果把表盘上显示的每一个控件称之为Complication)。苹果已经做使定制Complication在watchOS2的非常好的工作。WatchoOS现在包含ClockKit(表盘开发工具包),他包含了所有可定制化的Complication类型。自定义表盘的工作方式是非常简单的,只需要你的Watch Extension提供实现CLKComplicationDataSource协议,提供给ClockKit(表盘)数据。

Complication的五大分类:

一张图解释清楚:



 
 Complication 布局

提供给表盘(ClockKit)显示元素主要是通过CKComplicationTemplate,每一种家族的表盘元素 (complication)都有特定的子类,共提供用23个子类:



 通过自己的业务需求来选择数据展示所需模版。

 

Complication的Provider:

可以通过选择上面的模版来展示我们的数据。那么我们的数据如何显示在模版上的呢?我们可以通过设置模版的Providers(提供者),Providers是非常灵活的,提供了各种各样的Provider,如需要显示文本内容,我们有CLKTextProvider,它的子类CLKSimpleTextProvider非常常用,它有个text属性,设置这个属性提供给模版显示简单的文本内容。显示图片用CLKImageProvider提供给模版显示简单图片。使用CLKDateTextProvider,CLKTimeTextProvider和relativCLKRelativeDateTextProvider来为表盘显示时间。

/1.创建选择的模版
let tmpl = CLKComplicationTemplateModularLargeStandardBody()
//2.使用Provider设置要显示的数据
tmpl.headerImageProvider = CLKImageProvider(onePieceImage:UIImage(named: "soccer_ball")!)
tmpl.headerTextProvider = CLKTimeTextProvider(date: match.date!)
tmpl.body1TextProvider = CLKSimpleTextProvider(text: match.teamDesc!)
tmpl.body2TextProvider = CLKSimpleTextProvider(text: match.groupDesc!)

 自动生成的:CLKComplicationDataSource:

@implementation ComplicationController

#pragma mark - Timeline Configuration
//时间线前后
- (void)getSupportedTimeTravelDirectionsForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimeTravelDirections directions))handler {
    handler(CLKComplicationTimeTravelDirectionForward|CLKComplicationTimeTravelDirectionBackward);
}
//时间线起点
- (void)getTimelineStartDateForComplication:(CLKComplication *)complication withHandler:(void(^)(NSDate * __nullable date))handler {
    handler(nil);
}
//时间线终点
- (void)getTimelineEndDateForComplication:(CLKComplication *)complication withHandler:(void(^)(NSDate * __nullable date))handler {
    handler(nil);
}
//在锁屏时候是否隐藏Complication
- (void)getPrivacyBehaviorForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationPrivacyBehavior privacyBehavior))handler {
    handler(CLKComplicationPrivacyBehaviorShowOnLockScreen);
}

#pragma mark - Timeline Population
//获取当前complication
- (void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimelineEntry * __nullable))handler {
    // Call the handler with the current timeline entry
    handler(nil);
}
//获取limit个时间点前的complication
- (void)getTimelineEntriesForComplication:(CLKComplication *)complication beforeDate:(NSDate *)date limit:(NSUInteger)limit withHandler:(void(^)(NSArray<CLKComplicationTimelineEntry *> * __nullable entries))handler {
    // Call the handler with the timeline entries prior to the given date
    handler(nil);
}
//获取limit个时间点后的complication
- (void)getTimelineEntriesForComplication:(CLKComplication *)complication afterDate:(NSDate *)date limit:(NSUInteger)limit withHandler:(void(^)(NSArray<CLKComplicationTimelineEntry *> * __nullable entries))handler {
    // Call the handler with the timeline entries after to the given date
    handler(nil);
}

#pragma mark Update Scheduling
//多久更新时间线
- (void)getNextRequestedUpdateDateWithHandler:(void(^)(NSDate * __nullable updateDate))handler {
    // Call the handler with the date when you would next like to be given the opportunity to update your complication content
    handler(nil);
}

#pragma mark - Placeholder Templates
//complication的placeholder
- (void)getPlaceholderTemplateForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTemplate * __nullable complicationTemplate))handler {
    // This method will be called once per supported complication, and the results will be cached
    handler(nil);
}

@end

 

 感谢:

https://developer.apple.com/library/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/DesigningaComplication.html#//apple_ref/doc/uid/TP40015234-CH11-SW1

http://blog.csdn.net/wangjavafans/article/details/47763423

 

 

 

 

  • 大小: 52.7 KB
  • 大小: 30.8 KB
  • 大小: 107.2 KB
分享到:
评论
1 楼 啸笑天 2015-10-13  
http://www.onevcat.com/2015/08/watchos2/

相关推荐

    Swift.Development.for.the.Apple.Watch.149192520

    Add functionality to the notification system, including actionable items, and display them on the Watch face Design and build complications, Watch-face gadgets that can display quick snapshots of ...

    Android代码-android-WatchFace

    configuration Activity for configuring both the watch face styles and the complications themselves. We recommend you reuse the configuration code and follow the UX patterns in your watch face's ...

    Developing.for.Apple.Watch.2nd.Edition

    You won't just be creating apps - with Glances to provide timely information, notifications to inform your users of the latest updates, and watch face complications to show your users data as soon as ...

    iOS 9 Swift Programming Cookbook.pdf

    meaning that this book is entirely about iOS 9 subjects, including but not limited to the followings: Apple watchOS 2: so that you can create complications and standalone ?Watch apps UI Testing: ...

    Take.My.Money.Accepting.Payments.on.the.Web.1680501992

    Let Noel Rappin guide you through the setup and complications of dealing with online financial transactions. Go beyond just the interaction with the gateway service and build an application that will...

    gidti-sample.pdf

    By concentrating on the principles that make the theory work in practice, the author covers all the key ideas without getting involved in the complications of more advanced systems. This book takes a...

    MongoDB Applied Design Patterns 原版PDF by Copeland

    The book’s focus on the practical aspects of the MongoDB implementation makes it an ideal purchase for developers charged with bringing MongoDB’s scalability to bear on the particular problem you’...

    Twelveish:wel Twelveish-Android WearWear OS Watch Face

    Twelveish-Wear OS(Android Wear)的表盘 Twelveish是独特的Wear OS(Android Wear)表盘,它以文字(多种语言)显示大致时间。 它还在顶部显示确切的时间(数字时钟)和星期几,在下方略微显示日期和电池百分比,...

    WatchOS 2 by Tutorials v1.2

    If you are new to Swift 2, we suggest you read the Swift Apprentice, which takes you on a comprehensive tour through the Swift language, even if you are a complete beginner. If you are new to iOS, we ...

    Region Tracking

    Rather, complications arise due to the fact that the object undergoes changes in pose relative to the viewing camera, changes in illumination relative to light sources, and may even become partially ...

    Intelligent-Robot.doc

    Intelligent Robot What is known to ... when we rely on hormone to fight infection, cause many complications; when we eat sweet food to maintain blood glucose, the body's own blood sugar regulation abili

    rfc3027.rar_RFC3027_The Network

    RFC3027:Protocol Complications with the IP Network Address Translator

    About SFB and FBC of step7

    If they were modified by someone, you would no longer have uniform applications of the logic, and that could lead to complications. Descriptions and explanations for each of the SFB/SFCs are ...

    英文原版-Pathophysiology A 2in1 Reference for Nurses 1st Edition

    This unique 2-in-1 reference presents vital... Icons highlight complications, life-threatening disorders, emergency interventions, and effects of treatment on disease processes.,解压密码 share.weimo.info

    Wireless receiver architectures and design: rf, mixed signal, and digital signal

    The complications stem due to the high level of integration, low power, and low cost requirements imposed on the chip manufacturers. Until recently, most designers and architects designed for one ...

    英文原版-Adult Lumbar Scoliosis 1st Edition

    Providing a sound definition and review of the pertinent treatment goals for the management of adult lumbar scoliosis, this practical and comprehensive guide covers everything from pre-operative ...

    Address Book with Multiple Field Search(个人信息管理系统)

    For convenience, assume that none of the fields have spaces or commas in them, so you can read a comma separated file without worrying about those (non-algorithm related) complications. No need to ...

    英文原版-Endoscopic Spine Procedures 1st Edition

    surgical approaches and techniques, and potential complications for the different spine regions. Each chapter contains concise, step-by-step descriptions of the procedures enhanced by clearly labeled...

    英文原版-Clinical Physiology and Pharmacology The Essentials 1st Edition

    neurological, endocrine, cardiovascular, respiratory, renal, gastrointestinal and reproductive disorders, their symptoms, complications and usual treatment along with the actions and uses of some ...

Global site tag (gtag.js) - Google Analytics