Created
November 25, 2014 04:20
-
-
Save manchan/1e9cfae322f87583a2f7 to your computer and use it in GitHub Desktop.
AppleWatch Tutorial Emoji Zoom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// EmojiRow.swift | |
// EmojiWatch | |
// | |
// Created by matz on 2014/11/24. | |
// Copyright (c) 2014年 matz. All rights reserved. | |
// | |
import UIKit | |
import WatchKit | |
class EmojiRow: NSObject { | |
@IBOutlet weak var emojiRowLabel: WKInterfaceLabel! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// InterfaceController.swift | |
// EmojiWatch WatchKit Extension | |
// | |
// Created by matz on 2014/11/24. | |
// Copyright (c) 2014年 matz. All rights reserved. | |
// | |
import WatchKit | |
import Foundation | |
class InterfaceController: WKInterfaceController { | |
@IBOutlet weak var table: WKInterfaceTable! | |
var emojis:[[String]] = | |
[ | |
["Fall in love","😍"], | |
["Innocent","😇"], | |
["Pig","🐷"], | |
["Ghost","👻"], | |
["Beer","🍺"], | |
["Humster","🐹"] | |
] | |
override init(context: AnyObject?) { | |
// Initialize variables here. | |
super.init(context: context) | |
self.table.setNumberOfRows(self.emojis.count, withRowType: "EmojiRow") | |
for index in 0..<self.emojis.count { | |
var theRow = self.table.rowControllerAtIndex(index) as EmojiRow | |
theRow.emojiRowLabel.setText(self.emojis[index][1]) | |
} | |
} | |
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) { | |
self.pushControllerWithName("ZoomEmojiController", context: self.emojis[rowIndex]) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ZoomEmojiController.swift | |
// EmojiWatch | |
// | |
// Created by matz on 2014/11/24. | |
// Copyright (c) 2014年 matz. All rights reserved. | |
// | |
import UIKit | |
import WatchKit | |
class ZoomEmojiController: WKInterfaceController { | |
@IBOutlet weak var zoomEmojiLabel: WKInterfaceLabel! | |
@IBOutlet weak var definitionLabel: WKInterfaceLabel! | |
override init(context: AnyObject?) { | |
// Initialize variables here. | |
super.init(context: context) | |
var emoji:AnyObject = context! | |
// Emoji Zoom size | |
var font = UIFont.systemFontOfSize(90) | |
var specialString = NSAttributedString(string: emoji[1] as String, attributes: [NSFontAttributeName:font]) | |
self.zoomEmojiLabel.setAttributedText(specialString) | |
var definition = emoji[0] as String | |
self.definitionLabel.setText(definition) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment