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
| private var xoStickyHeaderKey: UInt8 = 0 | |
| extension UIScrollView { | |
| public var stickyHeader: StickyHeader! { | |
| get { | |
| var header = objc_getAssociatedObject(self, &xoStickyHeaderKey) as? StickyHeader | |
| if header == nil { | |
| header = StickyHeader() |
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
| public class StickyHeader: NSObject { | |
| /** | |
| The view containing the provided header. | |
| */ | |
| private(set) lazy var contentView: StickyHeaderView = { | |
| let view = StickyHeaderView() | |
| view.parent = self | |
| view.clipsToBounds = true | |
| return view |
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
| internal class StickyHeaderView: UIView { | |
| weak var parent: StickyHeader? | |
| internal static var KVOContext = 0 | |
| override func willMove(toSuperview view: UIView?) { | |
| if let view = self.superview, view.isKind(of:UIScrollView.self), let parent = self.parent { | |
| view.removeObserver(parent, forKeyPath: "contentOffset", context: &StickyHeaderView.KVOContext) | |
| } | |
| } |
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
| let headerView = Bundle.main.loadNibNamed("MyHeaderView", owner: nil, options: nil)?.first as! MyHeaderView | |
| tableview.stickyHeader.view = headerView | |
| tableview.stickyHeader.height = headerView.frame.height | |
| tableview.stickyHeader.minimumHeight = 64 |
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
| navigationView.frame = CGRect(x: 0, y: 0, width: headerView.frame.width, height: headerView.frame.height) | |
| navigationView.backgroundColor = .green | |
| navigationView.alpha = 0 | |
| table.stickyHeader.view = navigationView |
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
| class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
| // MARK: Outlets | |
| @IBOutlet weak var table: UITableView! | |
| // MARK: Properties | |
| var navigationView = UIView() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() |
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
| import UIKit | |
| enum ScreenType { | |
| case iPhone4 | |
| case iPhone5 | |
| case iPhone6 | |
| case iPhonePlus | |
| case iPhoneX | |
| case unknown | |
| } |
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
| func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
| print("Notification registration is success.") | |
| if #available(iOS 10.0, *) { | |
| let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) | |
| print(deviceTokenString) | |
| } else { | |
| let tokenParts = deviceToken.map { data -> String in | |
| return String(format: "%02.2hhx", data) |
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
| { | |
| "aps":{ | |
| "alert":"Test", | |
| "sound":"default", | |
| "badge":1, | |
| "actionType":"ana_sayfa" | |
| } | |
| } |
OlderNewer