Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Created June 4, 2016 12:00
Show Gist options
  • Save KentarouKanno/6c48bbd4e9bb218f4640deef71dfeae8 to your computer and use it in GitHub Desktop.
Save KentarouKanno/6c48bbd4e9bb218f4640deef71dfeae8 to your computer and use it in GitHub Desktop.
UIButton+Extension

UIButton+Extension

★ タイトル変更のアニメーションを無くす & タイトルの設定を簡単にする

extension UIButton {
    
    /// ボタンのタイトルの取得/設定
    var title: String? {
        get {
            return self.titleForState(.Normal)
        }
        set(newTitle) {
            UIView.performWithoutAnimation {
                self.setTitle(newTitle, forState: .Normal)
                self.layoutIfNeeded()
            }
        }
    }
}

// Usage

button.title = "No Animation Title"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment