I've been looking at answers and documentation but can't find anything on this topic. I'm fairly new to IOS development, so hopefully this question is relevant for here.
I have a TableView where user swipes right on a cell and font size of the label increases. However, in order to make it according to design specs I would also need to increase font weight. This is what I currently use:
self.infoLabel.font = [UIFont fontWithName:self.textLabel.font.familyName size:20 + 20*_intensityPercentage];
Other methods I've looked at seem to only switch bold on/off, however I'd need to adjust it continously.
Another problem with TableViewCell I'm facing is that UILabel would become blurier with left swipe. Is that even possible to do?
Any help is much appreciated. Thank you!
Per Is there a medium weight font between -systemFontOfSize: and -boldSystemFontOfSize:?, iOS doesn't support dynamic font weight. But since many fonts that ship with iOS ship with 3 or more "weights" within the font family you likely have more control available than normal / bold. For example, you might be able to dynamically rotate through HelveticaNeue-UltraLight to HelveticaNeue-Light to HelveticaNeue to HelveticaNeue-Medium to HelveticaNeue-Bold.
Check out http://www.iosfonts.com for a good dump of what fonts and weights are available to different versions of iOS.
Related
I am trying to make my app's storyboard universal for all Apple devices. I am having an issue with auto layout for some of my views. I am considering making a storyboard for each device since I think it will look better in the end, since I would be able to size my fonts and buttons differently for each type of screen.
What would you guys recommend I do?
Thanks
A good approach would be to use autolayouts and size classes. This approach would allow you to create only single storyboard for both iPhone and iPad. And you can easily size your fonts for different devices and also make buttons/views position/size differently for different screen sizes using size classes.
You should use size classes in which "any width , any height " is best for all layouts .
AFIK you can't just use size classes to determine the screen size and then set font sizes based on that. As can be seen when you edit in Storyboards, you can set the font sizes for specific size classes eg. compact, regular etc. but not iPhone 5, 6 or 6+. If you are wanting different font sizes for different screen sizes you could use UIAppearance to style your text elements in a centralised way or create IBOutlets to the UI elements and set the font size or other properties as required. With either of these you may still need to check the screen size with something like this:
switch UIScreen.mainScreen().bounds.size.width{
case kIphone6PlusWidth:
label.font = label.font.fontWithSize(20)
case kIphone6Width:
label.font = label.font.fontWithSize(18)
default:
label.font = label.font.fontWithSize(14)
}
Alternatively, separate storyboards for each will give you customisability but will lead to a fair amount of duplication with laying out the UI elements in different storyboards.
I'm trying to get my font sizes to scale with the change of system wide (via iOS Settings), but I am only able to get this functionality if I set Text Style to Body, etc in the Interface Builder.
I guess a way to do it could be to get the system font then factor that up a bit to get a new font-size to use:
let bodyFont = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
label.font = UIFont(descriptor: bodyFont.fontDescriptor(), size: bodyFont.pointSize * 1.2)
But is there a better way, because this feels wrong.
And is there a way to get notified when system font size change?
you need to listen to this notification: UIContentSizeCategoryDidChangeNotification
If you wanted to further increase those sizes, then you can do what you have suggested. Just be careful if the user chooses the really large font sizes in accessibility settings, as your fonts would be even bigger then.
I am trying to make an app that will let users select different fonts and rotate them around as desired.
What I need to know is what technology is being used in this app (see screenshots below)?
Is it UIKit, CATextLayer?
Are these texts / fonts available out of the box in apples UIKit module?
How can you let user resize or rotate text fonts.
Is there any sample apple project or sample code in github that I can use to look at?
All that looks like it can be done with custom fonts, none of them will be found in UIKit. You'll need to buy or find fonts that you have the rights to distribute. Here's a good reference for adding custom fonts to your project.
Once you have fonts installed. UILabel and other text holding controls can have their .font properties queried and set. And anything else you'd like to do to a view (like set up a rotational transform) is applicable to those controls, too.
I'd like different words in a UILabel to be different colors. Does this mean each word will need to be a different UILabel? I'm guessing yes, though sure would be nice to just put color codes in the label somehow, you know? I guess I'm a bit spoiled by text markup in HTML.
There is no proper UIRichTextView in iOS. It's high on my wish-list for iOS 6 (and there's some reason to believe we may get it then due to the release of Pages).
Your options are to use multiple UILabel views, NSString UIKit Additions, Core Text, UIWebView, or one of a few third-party frameworks such as:
NSAttributedString-Additions-for-HTML
CoreTextWrapper
OHAttributedLabel
OmniUI
All of the current solutions have different problems. The most common problem is that it's hard to get select and copy functionality to work with rich text unless you use a web view. Web views are incredibly annoying because they're asynchronous and you have to do a lot of your interactions in JavaScript.
I wish there were a better answer.
(Obligatory shilling: This topic is covered in depth in Chapter 18 of iOS 5 Programming Pushing the Limits.)
UILabel doesn't support segmented formatting (the entire thing can only have one format).
Have a look at OHAttributedLabel, which does what you want.
As far as I'm aware you'd need to have separate labels for each different coloured word. Depending what you're trying to do you may be able to make use of myLabel.textColor to change the colour of the periodically or on events etc.
First, let me state what brought this question about: I saw the green checkmark icon in this post and I would like to use it in my own application. However, since it looks so much like the UITableViewCellAccessoryDetailDisclosureButton my assumption is that this green checkmark icon is provided by the iPhone OS in some form or fashion.
So, my question is: how can I use the green checkmark icon and/or other OS-provided images in my own applications?
As a side question: where can I find a list of the OS-provided images (if they even exist)?
Thanks very much for any input :-)
This is not one of the standard images.
To see what you have available, you can add a UIBarButton in interface builder and try different system icons.