简体   繁体   中英

How to let Xcode know which asset to use for the target iPhone?

I am designing an app for iOS in SWIFT . I have decided that the auto layout will be compact and will be only for iPhone in portrait mode . I wanted to clear up a few hiccups on designing buttons for the 2 different screen ratios : the first being the iPhone 4s and the second ratio being the iPhone 5 and above . Because the new iPhones have a taller height, does that mean I will need to design 2 different ratios of buttons , and if so, how do I use them in Xcode? For example here's the stock apple calculator;

link to picture: http://imgur.com/mkIBghD

As you can see the the buttons on the taller iPhone have a square shape. The buttons on the 4s are more stubby . What do I need to do in Xcode to let the app know which asset to use for the respective phone and how would I implement that in Auto Layout? thanks

In order to do this you setup autolayout constraints. This will make the buttons change shape/size depending on the device. You do not need to have multiple assets because all the phones you are talking about have the same retina (2x) display.

You need to add three different sized images for a single Image Set in Images.xcassets . The sizes should be 1x for iPhone 4s, 2x for iPhone 6(It'll work for iPhone 5 too) and 3x for iPhone 6 plus. 这是一个示例,看起来像

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM