Skip to content

Instantly share code, notes, and snippets.

View iamchiwon's full-sized avatar
💭
I'm awake

Song Chiwon iamchiwon

💭
I'm awake
View GitHub Profile

Videos

@iamchiwon
iamchiwon / ios.settings.schemes.md
Created March 27, 2018 06:17 — forked from tzmartin/ios.settings.schemes.md
iOS Settings URL Scheme List

Settings URL schemes:

Note: < i=OS 5.1 use prefs:. > 5.1 use app-settings:

  • app-settings:root=General&path=About
  • app-settings:root=General&path=ACCESSIBILITY
  • app-settings:root=AIRPLANE_MODE
  • app-settings:root=General&path=AUTOLOCK
  • app-settings:root=General&path=USAGE/CELLULAR_USAGE
  • app-settings:root=Brightness
extension Array where Element: Equatable {
func exists(_ item: Element) -> Bool {
if let _ = self.indexOf(item) {
return true
}
return false
}
func indexOf(_ item: Element) -> Int? {
extension String {
func calcHeight(for width: CGFloat, font: UIFont) -> CGFloat {
let rect = CGSize(width: width, height: .greatestFiniteMagnitude)
let boundingRect = self.boundingRect(with: rect, options: .usesLineFragmentOrigin, attributes: [.font: font], context: nil)
return ceil(boundingRect.height)
}
func calcWidth(for height: CGFloat, font: UIFont) -> CGFloat {
@iamchiwon
iamchiwon / ViewCreator.swift
Created May 18, 2018 15:22
creating view programatically
@discardableResult
func createView<T>(_ view: T,
parent: UIView?,
setting: ((T) -> ())? = nil,
constraint: ((ConstraintMaker) -> ())? = nil) -> T where T: UIView {
switch parent {
case let stack as UIStackView:
stack.addArrangedSubview(view)
case let collectionCell as UICollectionViewCell:
@iamchiwon
iamchiwon / UIViewController+Rx.swift
Last active June 11, 2018 14:49
Rx Wrapping 예제 (methodInvoked)
import RxSwift
import RxCocoa
extension Reactive where Base: UIViewController {
var viewWillAppear: ControlEvent<Void> {
let source = methodInvoked(#selector(Base.viewWillAppear)).map { _ in }
return ControlEvent(events: source)
}
var viewDidAppear: ControlEvent<Void> {
let source = methodInvoked(#selector(Base.viewDidAppear)).map { _ in }
@iamchiwon
iamchiwon / Rx+Control.swift
Last active August 1, 2018 08:45
Control 이벤트에 sender 를 알게 한다.
//
// Rx+Control.swift
// ReactiveSample
//
// Created by iamchiwon on 2018. 8. 1..
// Copyright © 2018년 iamchiwon. All rights reserved.
//
import UIKit
import RxSwift
@iamchiwon
iamchiwon / LongTableViewHeaderViewController.swift
Last active September 17, 2018 13:34
Long-TableHeaderView Sample
//
// ViewController.swift
// TableViewExample
//
// Created by iamchiwon on 2018. 8. 2..
// Copyright © 2018년 ncode. All rights reserved.
//
import UIKit
import RxSwift
@iamchiwon
iamchiwon / globalVars.swift
Created August 27, 2018 09:41
iPhoneX margins
let screenSize = UIScreen.main.bounds.size
let screenWidth = screenSize.width
let screenHeight = screenSize.height
let statusHeight: CGFloat = {
guard #available(iOS 11.0, *), let window = UIApplication.shared.keyWindow else {
return 0
}
return window.safeAreaInsets.top
}()