![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the dimensions of a view in iOS App?
Getting dimensions of a view is easy, In this post, we will see how one can get the dimensions of a view in iOS.
Let’s get started,
Step 1 − Open Xcode and create a single view application and name it SampleView.
Step 2 − Open Main.storyboard and add UIView as shown below,
Step 3 − Create @IBOutlet of the view in ViewController.swift.
@IBOutlet var sampleView: UIView!
Step 4 − In viewDidLoad of ViewController.swift write the following code, print(sampleView.frame.size)
Run the application to see the size.
Complete code
import UIKit class ViewController: UIViewController { @IBOutlet var sampleView: UIView! override func viewDidLoad() { super.viewDidLoad() print(sampleView.frame.size) } }
Advertisements