Questions tagged [uiscreen]

A UIScreen object contains the bounding rectangle of the device’s entire screen. When setting up your application’s user interface, you should use the properties of this object to get the recommended frame rectangles for your application’s window.

153 questions
0
votes
1 answer

Why is my imageView not centered on UIScreen in Swift?

I have the following code: private func setupImageViews() { let width = UIScreen.main.bounds.width * 0.5 let x = (UIScreen.main.bounds.width * 0.5) - width/2 let y = UIScreen.main.bounds.width * 0.191 focusImageView =…
juboju1
  • 1
  • 1
0
votes
1 answer

SwiftUI, UIScreen.main.bounds.midY is not centered as default

Update: It looks like that it only happens on notch-less models. You don't need to do anything on newer models to make both swiftui and the bounds coordinate anchored on the same center. The red star is the default center on the View. The black star…
William Tong
  • 479
  • 7
  • 14
0
votes
1 answer

UIScreen.MainScreen.Brightness not changing Xamarin Forms

I was trying to change the brightness of my iOS app using a text entry box, and I found some stuff online which showed me how to create a dependency service and use UIScreen to set the brightness of the app so that is what I did. Here is the…
0
votes
1 answer

Swift -Get Child View Controller in Center of UIScreen using AVMakeRect

I add a vc as a child to another vc. I need the size of the child to get set using AVMakeRect so that it is smaller than the screen but still keeps its proportions. The problem is the child isn't centered, it goes either to far up off of the screen,…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
0
votes
1 answer

I am using SpriteKit to make a game, but my view only takes up what appears to be the safe area of the screen. How do I expand this view?

I am making a game using SpriteKit, and I want it to use the whole screen. However, right now, it is only using what looks to be the safe area. How can I make the view take up the entire screen? Below is the GameViewController code I am using: class…
helloworld12345
  • 176
  • 1
  • 4
  • 22
0
votes
1 answer

Get screen width to automatically fit content with UIScreen?

I'm using the newest version of Xcode and Swift. I have a Navigation Bar with a Navigation Item Title. On some devices with smaller screens this title is too long so it's getting truncated. My idea is: First I count how many characters fit on a…
David
  • 2,898
  • 3
  • 21
  • 57
0
votes
1 answer

Get Screen size irrespective of orientation

I have TableViewController with multiple cells. I am setting the height of these cells in the heightForRowAt method: override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return…
Patrick
  • 552
  • 5
  • 17
0
votes
1 answer

Why is UIScreen.main.bounds reversed and not static?

I find that UIScreen.main.bounds are really hard to grasp. They are inconsistent, and their values doesn't seem to reflect the device. They are not static but change when the device is rotated which is really confusing, and often the values are the…
Mark Tornej
  • 165
  • 9
0
votes
1 answer

Ios 13 screen brightness problem by swift

I'm working on a project, and I have to control the screen brightness. I use this to control: UIScreen.main.brightness = CGFloat(0.80) But, once I lock the screen and unlock, the screen brightness will change back to the system brightness, which…
0
votes
1 answer

Is UIScreen.main.bounds edge to edge?

I have a relatively simple question but I can't seem to find the answer anywhere. When I use: UIScreen.main.bounds.height Does this give me the height from the bottom edge of the screen all the way to the top or only till the safe area? For eg. is…
Ken
  • 1,155
  • 2
  • 19
  • 36
0
votes
0 answers

Why would UIScreen.main.bounds return (0.0, 0.0, 320.0, 568.0) for every device?

Context: I have inherited a legacy app still running in Swift 3, part of the AppDelegate looks like this: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool…
Joseph Beuys' Mum
  • 2,395
  • 2
  • 24
  • 50
0
votes
2 answers

UINavigationBar too low when using UIScreen.main.bounds as UIWindow frame

I am building an iOS app, deployment target 12.1, swift 4.2. The app uses container views and has a navigation bar at the top of the main screens, preferably right under the status bar. In the launchscreen storyboard, I have constrained Navigation…
0
votes
1 answer

iOS Screen recording detection

I tried to detect if screen capture is on for the application for iOS 11, to detect this the UIScreen.mainScreen.isCaptured property is used to check if it is recorded. It works fine for the first launch, when the app is terminated and launched…
Raghav
  • 625
  • 1
  • 12
  • 31
0
votes
2 answers

Xcode / Swift / UIScreen.main.bounds.size.height Returning 0

The code below is returning 0. I've tried all the samples I can find, but it still always returns 0. I'm on XCode 9.4.1 // Screen Size let screenSize = UIScreen.main.bounds let screenWidth = screenSize.width let screenHeight =…
Ricky Gore
  • 13
  • 2
0
votes
2 answers

Override screen size on simulator device

I am wondering if it possible to override screen size in a setting and reload your app. I want to do this so that if I have an iPhone X open, for example, I am able to open a debug menu on my app and default override the screen size, reload the app,…
Logan
  • 1,172
  • 9
  • 23