
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
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) } }
- Related Articles
- How to set background color of a View in iOS App?
- How to get the dimensions of a view in Android?
- How to Apply Gradient to the background view of the iOS Swift App?
- How to get the build/version number of an iOS App?
- How to get screen dimensions in pixels in Android app?
- How to get screen dimensions in pixels on Android App using Kotlin?
- How to Set opacity for View in iOS?
- How to set background color of a view in Android App
- How to hide the status bar in a iOS App using Swift?
- How to check notifications status for the iOS App
- How to add a border to the top and bottom of an iOS View?
- How to integrate a facebook login in swift for iOS App?
- How to create a WebView in an iOS App using Swift?
- How to use images while developing iOS App in a Simulator?
- How to run a timer in background within your iOS app

Advertisements