Miscellaneous iOS 12 Swift 5.0 programs that implement minimal examples for various random topics.
I will blog about each examples as time permits under this section of my website: http://www.h4labs.com/dev/ios/swift_cookbook.html For now, I'll place notes in README.md files with each project.
Please note that I'm creating most of these application as "Single View Applications" then adding views (e.g. UITableView) in code. It's a personal preference to not use Storyboards.
NSLayoutConstraint.activate([
centeredButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
centeredButton.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0)
])
- Buttons are equal size with 25 points between them
- StackView is centered horizontally
- StackView 10 points above bottom anchor
- Add some extra padding to button width and height
// Add some extra button padding
rightBtn.contentEdgeInsets = UIEdgeInsets.init(top: 5, left: 5, bottom: 5, right: 5)
- Subclass UITableViewController
- Custom Header Height
- Set Header Cell Color
- Fixed Row Height: tableView.rowHeight = 80
- CAShapeLayer() added to a UIViewController
- Use UIBezierPath to draw shapes
func rotateIt() {
UIView.animate(withDuration: 2,
delay: 0,
options: .curveEaseInOut,
animations: {
let transform = CGAffineTransform.identity.rotated(by: .pi)
self.label.transform = CGAffineTransform(rotationAngle: .pi)
self.aView.transform = transform
}, completion: {_ in
self.fadeIt()
})
}
func nextController(_ sender:UIButton) {
let secondViewController = SecondViewController()
self.navigationController?.pushViewController(secondViewController, animated: true)
}
func previousController(_ sender:UIButton) {
_ = self.navigationController?.popViewController(animated: true)
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
let navController = UINavigationController()
self.window?.rootViewController = navController
let topLevelController = ViewController()
navController.addChildViewController(topLevelController)
self.window?.makeKeyAndVisible()
return true
}
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
- Misc Notes
- Fix Mac OS installation error
convert ./screenshot.png -resize 25% screenshot-small.png; # Smaller screenshot
convert ./screenshot.png -resize 20% screenshot-toc.png; # Table of Contents screenshot
- Handle Device Rotation
- Pan Gesture|https://github.com/melling/ios_topics/blob/master/PanGesture/PanGesture
- PDF Creation
- Save Image to Photos
- Dispatch Async
- Core Data
- sqlite|
- Read plist