IOS TOPICS

IOS Introduction
Swift UI Label
Swift UI Button
Swift UI Text Field
Swift UI Slider
Swift UI Switch
Swift UI Stepper
Swift UI Date Picker
Swift UI Segmented Control
Views
Table View
Collection Views
SCROLL VIEW
iOS Content View
iOS View Controllers
iOS Bar interface
iOS Navigation interface
iOS Architect Pattern
iOS Libraries
iOS Web request and parsing
iOS user defaults
iOS Coredata and database

Adding labels and images to view


Adding labels and images to view

Note: all properties of Views can be applied to both images and labels used as subviews To use images either use SF symbols or import your own in the assets.xcassets folder accessible from the left hand side of the screen.

Note:

You can use buttons just as shown under SwiftUI buttons

ios output

Code:

.import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.lightGray let newView = UIView(frame: CGRect(x: 10, y: 100, width: 300, height: 80)) newView.backgroundColor = UIColor.blue view.addSubview(newView) newView.layer.cornerRadius=30 newView.layer.borderWidth=3 newView.layer.borderColor = UIColor.white.cgColor let banner = UILabel(frame: CGRect(x: 20, y: 20, width: 100, height: 30)) banner.text = "Hello" newView.addSubview(banner) let picture = UIImageView(frame: CGRect(x: 100, y: 100, width: 60, height: 60)) picture.image = UIImage(named : "pin") picture.contentMode = .scaleAspectFit newView.addSubview(picture) } }

Output:

ios output