Xcode changing a button background image for various devices - ios

How can I change button background image - I need one for all iPhones and another (due to size) for iPads. I have square buttons imitating keyboard with smaller background image. On iPad font on buttons is twice bigger, but they are not squares anymore. So I made bigger backgroud image to make them squares again, but how can I change that image only for iPads in storyboard. Is it possible?
Thanks.
on iPhones:
on Ipads:

You can design the layout using size class. The size class for iPad is R*R.

Related

iOS how to expand Image View to borders in Launch Screen?

I am 2 days into iOS app development, I am quite new. The very first thing I wanted to implement in my app is a Launch Screen using Storyboards (I heard there are other ways but I found this the easier). I have a vector-based PDF file (image) because I wanted to implement a gradient background without a loss in quality that supports all device resolutions.
I created an Image View in the Interface-Builder (IB) but it does not automatically stretch vertically and horizontally to fill the device length.
I simulate my results on an iPhone 14, only thin white margins appear, but on a large iPad, the majority of the screen is white. It's like as if the the image resolution is fixed across all devices.
No matter what resizing I try, I can't get it to work.
I come from an Android app development background so something like this is very easy to implement (we have fill_parent / match_parent to stress the view to its containing parent view dimensions). Is such a behavior possible on iOS ?
You have to apply constraint on the image in launch screen.

iOS, launch screen image same proportional size on different devices without blurring?

I want have an image on my launch screen which occupies the same amount of the screen on different devices.
At the moment I have a logo which is about the right size on iPhone 4s, but on iPhone 6 Plus it's too small. Obviously these devices are in the same autolayout class.
I know I could use proportional sizing, but this will stretch the images and make them look fuzzy.
Also with it being a launch screen I can't use code for drawing or custom controls.
I guess I need some way to determine different devices in my constraints.
Add LaunchScreen asset group to your Assets. Then it will be possible to assign custom image for each screen resolution.

Font size in button change as screen size does

In my IOS app there will be buttons with text on them. Everything looks fine only on Iphone 7, because it has screen size I've created on. When I switch to another screen size e.g. in simulator, text in buttons is truncated in the middle.
The best option to solve this problem would be to make font size scalable as screen size changes or slidable. How to make text in buttons visible at all in all screen sizes?

UIButton image. Auto size to real image size. Device based

I have a universal application.
I have a main menu with 2 buttons. The button have a different size\shape on ipad and on iphone.
btn_main_all#2x~ipad.png
btn_main_all.png
I'm using xcode filename to get the good image from each device(work great). But the image are not resized to the good specific size. (i've try each combinaison in storyboard... top left, fit..., etc.
How can I have the button to get the real image size ?

Same button position in relation to iPhone 5/6/6+ screen resolution in Xcode 6

I'm coding a remote control with a background (designed in Photoshop) already for the iPhone 6+ with the proper resolution, which I use with an UIImageView at full size.
I disabled Autolayout/Size Classes and set the size to Inferred. Further I uploaded all relevant LaunchImages for proper scaling.
The UIImageView scales properly for all screen sizes, but the buttons I put over the background are moving.
For example:
All buttons (over 1-9, Power Off, Menu ecc.) should always stay at the same position (in releation to the selected device and screen resolution).
I can't get it, that all buttons stay over the designed photoshop elements.
Please give me a good advice, to solve this issue.
I would recommend using size classes and Autolayout. This type of thing is exactly what they are made for.
This youtube video is a great introduction to size classes and some Autolayout:
https://www.youtube.com/watch?v=IwSTXY0awng&feature=youtu.be

Resources