Updated 4 March 2022
A Scroll View in iOS is the view that adjusts its size according to its content. We need Scroll View when we know that the size of the content is more then the screen that’s why we need to Scroll the content to view the whole content.
The specialty of Scroll View is that the content of the page loads once the page loaded after that we can see all content by scrolling up and scrolling down.
A Scroll View in iOS has a big bunch of properties, but here we gonna with the simple Scroll View.
Indicators: It has two types of indicators if scrolling in the vertical direction vertical indicator show at the screen and if scrolling in the horizontal direction the horizontal indicator show at the screen. You can also hide the indicator.
Bouncing: When scrolling bouncing horizontally, bouncing vertically, bouncing on zoom, bouncing on scroll. We can also stop bouncing by just uncheck this property.
Scroll Enabled: Check this property for scrolling and uncheck for stopping scrolling.
Now, let’s start our demo application of Scroll View in iOS. So, please follow the below steps carefully.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import UIKit class ViewController: UIViewController { @IBOutlet weak var scrlView: UIScrollView! @IBOutlet weak var label1: UILabel! @IBOutlet weak var label2: UILabel! @IBOutlet weak var label3: UILabel! @IBOutlet weak var label4: UILabel! @IBOutlet weak var view1: UIView! @IBOutlet weak var view2: UIView! @IBOutlet weak var view3: UIView! @IBOutlet weak var view4: UIView! override func viewDidLoad() { super.viewDidLoad() scrlView.backgroundColor = UIColor.white label1.text = "View One" label2.text = "View Two" label3.text = "View Three" label4.text = "View Four" view1.backgroundColor = UIColor.blue view2.backgroundColor = UIColor.blue.withAlphaComponent(0.5) view3.backgroundColor = UIColor.blue.withAlphaComponent(0.3) view4.backgroundColor = UIColor.blue.withAlphaComponent(0.1) } } |
Here we have attached the image for reference.
This is the simple Scroll View in iOS application.
Thanks for reading this blog, for detailed info please click here
I hope this blog will help you to learn about Scroll View in iOS and you will be able to implement the same.
Happy Learning ✍️
For more blogs please click here.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.