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 readImageBuffer(fromVideo videoURL: URL) { | |
let asset = AVAsset(url: videoURL) | |
let assetTrack = asset.tracks.first! | |
let assetReader = try! AVAssetReader(asset: asset) | |
let outputSettings: [String: Any] = [ | |
String(kCVPixelBufferPixelFormatTypeKey): kCVPixelFormatType_32BGRA, | |
String(kCVPixelBufferWidthKey): 513, | |
String(kCVPixelBufferHeightKey): 513, | |
] |
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
//generate a file url to store the video. some_image.jpg becomes some_image.mov | |
guard let outputMovieURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("output.mov") else { | |
fatalError("somehting went wrong") //an error i made up | |
} | |
//delete any old file | |
do { | |
try FileManager.default.removeItem(at: outputMovieURL) | |
} catch { | |
print("Could not remove file \(error.localizedDescription)") | |
} |
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 scrollViewDidScroll(_ scrollView: UIScrollView) { | |
// get the content offset for y-axis | |
let contentOffsetheight = scrollView.contentOffset.y | |
//if the value is negative | |
if contentOffsetheight < 0 { | |
//change the anchors | |
contentViewTopAnchor.constant = contentOffsetheight | |
headerViewHeightAnchor.constant = 450 + (-contentOffsetheight) | |
} | |
} |
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
parentScrollView.delegate = self |
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 setupView(){ | |
view.backgroundColor = .black | |
//setup the scrollView | |
view.addSubview(parentScrollView) | |
parentScrollView.fillSuperview() | |
parentScrollView.contentSize = CGSize(width: DeviceSize.width, | |
height: DeviceSize.height*2) | |
//setup the content view | |
parentScrollView.addSubview(contentView) |
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 setupView(){ | |
view.backgroundColor = .black | |
//setup the scrollView | |
view.addSubview(parentScrollView) | |
parentScrollView.fillSuperview() | |
parentScrollView.contentSize = CGSize(width: DeviceSize.width, | |
height: DeviceSize.height*2) | |
//setup the content view | |
parentScrollView.addSubview(contentView) |
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
var contentViewTopAnchor: NSLayoutConstraint! | |
var headerViewHeightAnchor: NSLayoutConstraint! |
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 | |
// Reference Video: https://youtu.be/iqpAP7s3b-8 | |
struct AnchoredConstraints { | |
var top, leading, bottom, trailing, width, height: NSLayoutConstraint? | |
} | |
let DeviceSize = UIScreen.main.bounds.size |
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 parentScrollView: UIScrollView = { | |
let sv = UIScrollView() | |
sv.contentInsetAdjustmentBehavior = .never | |
return sv | |
}() | |
let contentView: UIView = { | |
let view = UIView() | |
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
struct HomeView: View { | |
@EnvironmentObject var subscription: Subscription | |
var body: some View { | |
VStack{ | |
if subscription.isSubscribed{ | |
Text("Welcome Premium User.") | |
} | |
else{ | |
Text("Welcome to the App.") | |
} |
NewerOlder