ios_topics
                                
                                 ios_topics copied to clipboard
                                
                                    ios_topics copied to clipboard
                            
                            
                            
                        Small example iOS programs in Swift 5
iOS Topics in Swift 5
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.
AutoLayout Centered Button using iOS9 Anchors

NSLayoutConstraint.activate([
    centeredButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
    centeredButton.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0)
    ])
AutoLayout Two Button in StackView

- 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)
Various UIButtons in a UIStackView

UIAlertController Example

Simple UIView Subclass

Gradient Layer

Basic UITableViewController Subclass

- Subclass UITableViewController
- Custom Header Height
- Set Header Cell Color
- Fixed Row Height: tableView.rowHeight = 80
Basic UITableViewController with Custom UITableViewCell

UITableViewController Subclass with Sections

UITableViewController Subclass with Sections and an Index

Custom UITableView Header

UICollectionViewController Subclass

UICollectionViewController Delegate

UICollectionView with Custom Cell

UISwitch

UISegmentedControl

CAShapeLayer with Basic Shapes

- CAShapeLayer() added to a UIViewController
- Use UIBezierPath to draw shapes
Animate the Drawing of a Bezier Line

Animate the Drawing of a Bezier Circle

Transition from One View to Another with a Curl Up

Transition from One View with UILabel to Another with a Curl Up

Single Tap Gesture on View

Simple AVAudioPlayer Example

Size, Rotate, and Fade Transforms

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()
        })
    }
Simple UIView Subclass

A StackView in a StackView

Programmatically Show/Push ViewController

func nextController(_ sender:UIButton) {
    let secondViewController = SecondViewController()
    self.navigationController?.pushViewController(secondViewController, animated: true)
}
func previousController(_ sender:UIButton) {
    _ = self.navigationController?.popViewController(animated: true)
}
No Nib Project - All Code

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
}
UIPickerView

Countdown Timer

 timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
Core Data
Game Clock
WebView
AppRotation
- Misc Notes
ImageMagick
- Fix Mac OS installation error
- http://stackoverflow.com/questions/22715738/imagemagick-error
convert ./screenshot.png -resize 25% screenshot-small.png; # Smaller screenshot
convert ./screenshot.png -resize 20% screenshot-toc.png; # Table of Contents screenshot
Ideas and In-Progress
- 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
Old
AutoLayout Centered Button
