Upgrade to Pro — share decks privately, control downloads, hide ads and more …

(UI)Switch は つくれる

gaussbeam
February 14, 2018

(UI)Switch は つくれる

2018.02.14 iOS UI実装勉強会 #2 @ Sansan

gaussbeam

February 14, 2018
Tweet

More Decks by gaussbeam

Other Decks in Programming

Transcript

  1. Customizing the Appearance of the Switch var onTintColor: UIColor? The

    color used to tint the appearance of the switch when it is turned on. var tintColor: UIColor! The color used to tint the outline of the switch when it is turned off. var thumbTintColor: UIColor? The color used to tint the appearance of the thumb. var onImage: UIImage? In iOS 6 and earlier, the image displayed when the switch is in the on position. var offImage: UIImage? In iOS 6 and earlier, the image displayed when the switch is in the off position. https://developer.apple.com/documentation/uikit/uiswitch TintColor͔͠ΧελϚΠζͰ͖ͳ͍
  2. public class CustomSwitch: UIControl { var isOn: Bool = true

    var isAnimating: Bool = false var animationDuration: TimeInterval = 0.5 var onTintColor: UIColor = .blue var offTintColor: UIColor? = .lightGray } ɾ ɾ ɾ
  3. func animate() { self.isAnimating = true UIView.animate( … completion: {

    self.sendActions(for: .valueChanged) self.isAnimating = false } }
  4. ࢀߟ • Making custom UISwitch (Part 1) – Factory.hr –

    Medium • https://medium.com/@milenko_52829/making-custom-uiswitch-part-1-cc3ab9c0b05b