https://github.com/melling/ios_topics
Small example iOS programs in Swift 5
https://github.com/melling/ios_topics
autolayout ios-topics uitableviewcontroller-subclass uiview-subclass
Last synced: 10 months ago
JSON representation
Small example iOS programs in Swift 5
- Host: GitHub
- URL: https://github.com/melling/ios_topics
- Owner: melling
- License: cc0-1.0
- Created: 2016-03-08T16:07:13.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T19:24:34.000Z (about 6 years ago)
- Last Synced: 2025-05-07T21:46:01.670Z (about 1 year ago)
- Topics: autolayout, ios-topics, uitableviewcontroller-subclass, uiview-subclass
- Language: Swift
- Homepage: http://www.h4labs.com/dev/ios/swift.html
- Size: 5.78 MB
- Stars: 73
- Watchers: 5
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/melling/ios_topics/blob/master/ButtonCenteredWithAnchors/ButtonCenteredWithAnchors)

```swift
NSLayoutConstraint.activate([
centeredButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
centeredButton.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0)
])
```
## [AutoLayout Two Button in StackView](https://github.com/melling/ios_topics/blob/master/TwoButtonsInStackView/TwoButtonsInStackView)

+ 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
```swift
// Add some extra button padding
rightBtn.contentEdgeInsets = UIEdgeInsets.init(top: 5, left: 5, bottom: 5, right: 5)
```
## [Various UIButtons in a UIStackView](https://github.com/melling/ios_topics/blob/master/ButtonsInStackView/ButtonsInStackView)

## [UIAlertController Example](https://github.com/melling/ios_topics/blob/master/AlertControllers/AlertControllers)

## [Simple UIView Subclass](https://github.com/melling/ios_topics/blob/master/SimpleUIViewSubclass/SimpleUIViewSubclass)

## [Gradient Layer](https://github.com/melling/ios_topics/blob/master/GradientView/GradientView)

## [Basic UITableViewController Subclass](https://github.com/melling/ios_topics/blob/master/SimpleTableView/SimpleTableView)

+ Subclass UITableViewController
+ Custom Header Height
+ Set Header Cell Color
+ Fixed Row Height: tableView.rowHeight = 80
## [Basic UITableViewController with Custom UITableViewCell](https://github.com/melling/ios_topics/blob/master/TableViewWithCustomCell/TableViewWithCustomCell)

## [UITableViewController Subclass with Sections](https://github.com/melling/ios_topics/blob/master/TableViewWithSections/TableViewWithSections)

## [UITableViewController Subclass with Sections and an Index](https://github.com/melling/ios_topics/blob/master/TableViewWithIndex/TableViewWithIndex)

## [Custom UITableView Header](https://github.com/melling/ios_topics/blob/master/CustomTableViewHeaderCell/CustomTableViewHeaderCell)

## [UICollectionViewController Subclass](https://github.com/melling/ios_topics/blob/master/CollectionViewBasic/CollectionViewBasic)

## [UICollectionViewController Delegate](https://github.com/melling/ios_topics/blob/master/CollectionViewDelegate/CollectionViewDelegate)

## [UICollectionView with Custom Cell](https://github.com/melling/ios_topics/blob/master/CollectionViewWithCustomCell/CollectionViewWithCustomCell)

## [UISwitch](https://github.com/melling/ios_topics/blob/master/SwitchController/SwitchController)

## [UISegmentedControl](https://github.com/melling/ios_topics/blob/master/SegmentController/SegmentController)

## [CAShapeLayer with Basic Shapes](https://github.com/melling/ios_topics/blob/master/ShapeLayer/ShapeLayer)

+ CAShapeLayer() added to a UIViewController
+ Use UIBezierPath to draw shapes
## [Animate the Drawing of a Bezier Line](https://github.com/melling/ios_topics/blob/master/LineDrawingAnimation/LineDrawingAnimation)

## [Animate the Drawing of a Bezier Circle](https://github.com/melling/ios_topics/blob/master/CircleDrawingAnimation/CircleDrawingAnimation)

## [Transition from One View to Another with a Curl Up](https://github.com/melling/ios_topics/blob/master/TransitionWithView/TransitionWithView)

## [Transition from One View with UILabel to Another with a Curl Up](https://github.com/melling/ios_topics/blob/master/TransitionWithViewAndLabels/TransitionWithViewAndLabels)

## [Single Tap Gesture on View](https://github.com/melling/ios_topics/blob/master/TapGesture/TapGesture)

## [Simple AVAudioPlayer Example](https://github.com/melling/ios_topics/blob/master/PlayAudio/PlayAudio)

## [Size, Rotate, and Fade Transforms](https://github.com/melling/ios_topics/blob/master/ViewTransforms/ViewTransforms)

```swift
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](https://github.com/melling/ios_topics/blob/master/CustomUIView/CustomUIView)

## [A StackView in a StackView](https://github.com/melling/ios_topics/blob/master/StackViewsInStackViews/StackViewsInStackViews)

## [Programmatically Show/Push ViewController](https://github.com/melling/ios_topics/blob/master/ShowViewController/ShowViewController)

```swift
func nextController(_ sender:UIButton) {
let secondViewController = SecondViewController()
self.navigationController?.pushViewController(secondViewController, animated: true)
}
```
```swift
func previousController(_ sender:UIButton) {
_ = self.navigationController?.popViewController(animated: true)
}
```
## [No Nib Project - All Code](https://github.com/melling/ios_topics/blob/master/NoNibAllCodeSwift/NoNibAllCodeSwift)

```swift
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](https://github.com/melling/ios_topics/blob/master/PickerViewDemo/PickerViewDemo)

## [Countdown Timer](https://github.com/melling/ios_topics/blob/master/CountDownTimer/CountDownTimer)

```swift
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
```
## [Core Data](https://github.com/melling/ios_topics/blob/master/CoreDataHighScores/CoreDataHighScores)
## [Game Clock](https://github.com/melling/ios_topics/blob/master/GameClock/GameClock)
## [WebView](https://github.com/melling/ios_topics/blob/master/WebView/WebView)
## [AppRotation](https://github.com/melling/ios_topics/blob/master/AppRotation/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](https://github.com/melling/ios_topics/blob/master/AppRotation/AppRotation)
- [Pan Gesture](AppRotation://github.com/melling/ios_topics/blob/master/PanGesture/PanGesture/screenshot-toc.png)|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](https://github.com/melling/ios_topics/blob/master/CenteredAutoLayoutButton/CenteredAutoLayoutButton)
