iphone - How to scale attributed string text based on Screen size- iOS Swift? -
so have app content appears in textview. using attributed strings part of text contains links websites. problem content font size. small in ipads. seems fine in iphones. below code using.
let attributedstring = nsmutableattributedstring(string: "about\n common room virtual fireplace app designed love 5x entrepreneur, arjun rai. goal of create ultimate mobile , relaxing ambience anywhere , anytime. rai’s passion fireplaces along minimalism in art has led him build several apps , startups on years since teenager. common room yet effort bringing beautiful experiences everyone...just bit more relaxing time around. :) follow him @ twitter.com/arjunraime") attributedstring.addattribute(nslinkattributename, value: "http://arjunrai.me/", range: nsrange(location: 92, length: 10)) attributedstring.addattribute(nslinkattributename, value: "https://itunes.apple.com/in/genre/ios/id36?mt=8", range: nsrange(location: 14, length: 33)) attributedstring.addattribute(nsfontattributename, value: uifont(name: "avenirnext-ultralight", size: 12.0)!, range: nsrange(location: 0, length: 506)) attributedstring.addattribute(nsforegroundcolorattributename, value: uicolor.white, range: nsrange(location: 0, length: 506)) attributedstring.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 0, length: 5)) attributedstring.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 15, length: 33)) attributedstring.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 92, length: 11)) attributedstring.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 470, length: 36)) attributedstring.addattribute(nsparagraphstyleattributename, value: paragraph, range: nsrange(location: 0, length: 506)) infotextview.attributedtext = attributedstring /*************************how works****************/ let attributedstring1 = nsmutableattributedstring(string: "how works?\n common room works alongside of favorite music apps. start common room app first followed opening favorite music app play songs return back. can control volume of fire crackle turn on , off via menu in common room. enjoy!") attributedstring1.addattribute(nsfontattributename, value: uifont(name: "avenirnext-ultralight", size: 12.0)!, range: nsrange(location: 0, length: 305)) attributedstring1.addattribute(nsforegroundcolorattributename, value: uicolor.white, range: nsrange(location: 0, length: 305)) attributedstring1.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 0, length: 13)) attributedstring1.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 60, length: 21)) attributedstring1.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 231, length: 9)) attributedstring1.addattribute(nsfontattributename, value: uifont(name: "avenirnext-medium",size: 12.0)!, range:nsrange(location: 258, length: 12)) attributedstring1.addattribute(nsparagraphstyleattributename, value: paragraph, range: nsrange(location: 0, length: 305)) infotextview1.attributedtext = attributedstring1
is there way of making text scale automatically based on screen size? adaptive sizing way becuase did not make visible difference in output.
please see different outputs current code.
ipad screen output
iphone screen output
can let me know how this?
Comments
Post a Comment