Created
August 1, 2016 04:22
-
-
Save kusalshrestha/6e702fc6c2659598f8dbb985d3c2e1b1 to your computer and use it in GitHub Desktop.
UITableViewHeaderFooterView Text Alignment
This file contains hidden or 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
| // | |
| // String+Extensions.swift | |
| // | |
| // | |
| // Created by Kusal Shrestha on 5/30/16. | |
| // | |
| // | |
| import UIKit | |
| extension UITableView { | |
| var headerTitleAlignment: NSTextAlignment { | |
| get { | |
| if #available(iOS 9.0, *) { | |
| return UILabel.appearanceWhenContainedInInstancesOfClasses([UITableViewHeaderFooterView.self]).textAlignment | |
| } | |
| return .Left | |
| } | |
| set(alignment) { | |
| if #available(iOS 9.0, *) { | |
| UILabel.appearanceWhenContainedInInstancesOfClasses([UITableViewHeaderFooterView.self]).textAlignment = alignment | |
| } else { | |
| // Fallback on earlier versions | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment