Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ios - Different font size for different devices in Xcode 6

I want to use the same text on different devices. I am using the universal storyboard but I can't find any constraints for the font size. I know that you can use different text fields on different devices with the new layout but then I need to add some logic in the code. I want to use same text field.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Select your text field in your storyboard. In the attributes inspector you will see a small '+' to the left of the font selector. This will allow you to choose size-class specific stuff for your text.

Size classes were added to iOS 8 when Apple introduced Universal Storyboards which let you design for both iPad and iPhone with the same Storyboard file. At the bottom of the Storyboard design window you'll see the (default) 'w Any h Any' button. This gives you access to combinations of the compact and regular size classes. These available combinations let you implement design, say for only the iPhone in landscape, or maybe the iPad in both orientations. You have full control.

For your font related question, you access the size-class control through the '+' sign I mentioned above.

This is a good explanation and tutorial: Wenderlich size classes

and in Apple's own words: Apple size classes

EDIT: - If you really want to have different font sizes for different screen sizes, then this answer should help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...