< onga blog >

開発に関することなど。

WatchKit Catalog

Onga.inc

WatchKit Catalogがあったのでswiftの勉強をかねつつ解析してみようと思います。

f:id:loosefingers:20150208231651j:plain

https://developer.apple.com/library/prerelease/ios/samplecode/WKInterfaceCatalog/Listings/README_md.html

まずは時計らしくタイマー機能から、

WKInterfaceTimer で設定できるのは、4つのパラメータです。 シンプルですね。

setDateで初期値を設定できます。 連続して使用する場合などに使えそうです。

func setDate(_ date: NSDate) 

カラーの設定

func setTextColor(_ color: UIColor)

タイマーのスタート

func start()

タイマーのストップ

func stop()

WKInterfaceMap マップを扱うクラスです。

マップの表示範囲を設定します。

func setVisibleMapRect(_ mapRect: MKMapRect)

マップの表示地域を変更します。

func setRegion(_ coordinateRegion: MKCoordinateRegion)

map上にピンを立てるたてる事ができます。

addAnnotation(_:withImage:centerOffset:)
addAnnotation(_:withImageNamed:centerOffset:)
addAnnotation(_:withPinColor:)

map上からpinを削除します。

func removeAllAnnotations()