This file contains 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 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 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 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 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 | |
import AVKit | |
class ViewController: UIViewController { | |
let playerController = AVPlayerViewController() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
This file contains 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
NotificationCenter.default.addObserver(self, selector: #selector(onRotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) |
This file contains 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
@objc func onRotated() { | |
// portrait | |
if UIDeviceOrientationIsPortrait(UIDevice.current.orientation) { | |
} | |
// landscape | |
else if UIDeviceOrientationIsLandscape(UIDevice.current.orientation) { | |
This file contains 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
@objc func onRotated() { | |
// portrait | |
if UIDeviceOrientationIsPortrait(UIDevice.current.orientation) { | |
playerController.view.frame = CGRect(x: 0, y: 200, width: UIScreen.main.bounds.width, height: 250) | |
} | |
// landscape | |
else if UIDeviceOrientationIsLandscape(UIDevice.current.orientation) { | |
playerController.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) |
This file contains 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 | |
import AVKit | |
class ViewController: UIViewController { | |
let playerController = AVPlayerViewController() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
This file contains 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 | |
import StoreKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
OlderNewer