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
func imageFromColor(color:UIColor) -> UIImage { | |
let rect = CGRectMake(0.0, 0.0, 1.0, 1.0) | |
UIGraphicsBeginImageContext(rect.size) | |
let context = UIGraphicsGetCurrentContext() as CGContextRef | |
CGContextSetFillColorWithColor(context, color.CGColor) | |
CGContextFillRect(context, rect) | |
let image = UIGraphicsGetImageFromCurrentImageContext() |
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
let title = String("It's latest news! ") | |
var attributedString = NSMutableAttributedString(string: title) | |
let attachment = NSTextAttachment() | |
attachment.image = UIImage(named: "NoticeNewIcon") | |
let attachmentAttributedString = NSAttributedString(attachment: attachment) | |
attributedString.appendAttributedString(attachmentAttributedString) |
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
class TDTextAttachment: NSTextAttachment { | |
var topSpace: Float = 0.0 | |
convenience init(image: UIImage, topSpace: Float = 0.0) { | |
self.init() | |
self.image = image | |
self.topSpace = 0.0 | |
} | |
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
// | |
// UTTextField.swift | |
// YFGAddressBook | |
// | |
// Created by KimYoonBong on 2015. 8. 28.. | |
// Copyright © 2015년 YMP. All rights reserved. | |
// | |
import UIKit |
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
func textFieldDidBeginEditing(textField: UITextField) { | |
self.showMessageToUser(nil) | |
} | |
func textFieldDidEndEditing(textField: UITextField) { | |
if textField.text?.characters.count <= 0 { | |
if let hasLabel = textField as? UTTextField { | |
hasLabel.changeStatus(.Normal) | |
} |
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
let paths = NSSearchPathForDirectoriesInDomains(.PicturesDirectory, .UserDomainMask, true) | |
let path = paths[0] | |
if !NSFileManager.defaultManager().fileExistsAtPath(path) { | |
print("have to create directory...") | |
do { | |
try NSFileManager.defaultManager().createDirectoryAtPath(path, withIntermediateDirectories: true, attributes: nil) | |
} | |
catch let error as NSError { | |
print(error) |
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
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) { | |
self.handleShortCutItem(shortcutItem) | |
} | |
func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) { | |
guard let rootViewCntrlr = self.window?.rootViewController else { | |
return | |
} | |
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
let firstShortCutIcon = UIApplicationShortcutIcon(templateImageName: "ShortCut01") | |
let firstFunctionShortCutItem = UIApplicationShortcutItem(type: "com.y8k.touchExample.function01", localizedTitle: "Member Func. 1", localizedSubtitle: "Dynamic short cut item", icon: firstShortCutIcon, userInfo: nil) | |
let secondShortCutIcon = UIApplicationShortcutIcon(templateImageName: "ShortCut02") | |
let secondFunctionShortCutItem = UIApplicationShortcutItem(type: "com.y8k.touchExample.function02", localizedTitle: "Member Func. 2", localizedSubtitle: "Dynamic short cut item", icon: secondShortCutIcon, userInfo: nil) | |
UIApplication.sharedApplication().shortcutItems = [firstFunctionShortCutItem, secondFunctionShortCutItem] |
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
class PresentedViewController: UITableViewController, UIViewControllerPreviewingDelegate { | |
... | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
registerForPreviewingWithDelegate(self, sourceView: view) | |
} |
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
func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { | |
guard let indexPath = self.tableView.indexPathForRowAtPoint(location), cell = self.tableView.cellForRowAtIndexPath(indexPath) else { return nil } | |
let selectedData = self.data[indexPath.row] | |
var detailViewCntrlr: UIViewController? | |
switch selectedData.type { | |
case .List: | |
detailViewCntrlr = self.storyboard?.instantiateViewControllerWithIdentifier("DETAIL_LIST_SCREEN") |
OlderNewer