Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

get device height and width wift

//In Swift 5.0
let screenSize: CGRect = UIScreen.main.bounds

//Swift 4.0
// Screen width.
public var screenWidth: CGFloat {
    return UIScreen.main.bounds.width
}
// Screen height.
public var screenHeight: CGFloat {
    return UIScreen.main.bounds.height
}

//In Swift 3.0
let screenSize = UIScreen.main.bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height

//In older swift:
//Do something like this:
let screenSize: CGRect = UIScreen.mainScreen().bounds
//then you can access the width and height like this:
let screenWidth = screenSize.width
let screenHeight = screenSize.height
Comment

PREVIOUS NEXT
Code Example
Swift :: ui alert swift yes no 
Swift :: swift set view order front 
Swift :: delete padding list swiftui 
Swift :: swift pop to specific view controller 
Swift :: xcode hide keyboard when touch background storyboard 
Swift :: add toggle without text swiftui 
Swift :: pop view swiftui 
Swift :: xcode perform action when return key pressed text field 
Swift :: swift get a rectangle centered 
Swift :: pop the view controller xcode 
Swift :: switches xcode 
Swift :: connect old iphone with latest xcode 12 or 13 
Swift :: swift go back to previous view controller 
Swift :: add corner radius to uiview swift 
Swift :: alert swiftui 
Swift :: swift qrcode scanner 
Swift :: swift initialize a view 
Swift :: ios swift create new background thread 
Swift :: try? as? in swiftui 
Swift :: hide scroll view indicators bar swiftui 
Swift :: how to set the stack color in swiftui 
Swift :: swift file size from url 
Swift :: convert image to base64 swift Ui 
Swift :: how to recieve hex value from NSData swift 
Swift :: Single Line Comment 
Swift :: swift create lazy property 
Swift :: swift out of bound elelemnt 
Swift :: declaration of array in swift by two methods. 
Swift :: auto layout issue in tableview 
Swift :: Swift Library Function 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =