Menu
  • HOME
  • TAGS

Why am I unable to save my UIFontDescriptor into a variable?

objective-c,ios7,uikit,uifont,uifontdescriptor

Initially, I counted 4 open brackets and 3 close brackets, which will cause an error. Additionally, fontWithDescriptor: should be fontWithDescriptor:size:, which is probably the expected expression. Finally, using fontWithDescriptor:size: to define a font, then asking for its descriptor is redundant, so a cleaner version of the command is this: UIFontDescriptor...

UIFont Class Crashed app in Swift

ios,swift,class,uifont

Since you're adding your own personal functionality to a Type, I think you should use an extension, declare this extension outside of your class: extension UIFont { // You can set a default value for the size if the user doesn't provide one. class func defaultFont(size: CGFloat = 12) ->...

UIFont doesn't set the correct font name when pointSize is 0

ios,uifont

In the documentation: fontSize The size (in points) to which the font is scaled. This value must be greater than 0.0. You are trying to implement behaviour which is not supported. An 'incorrect' result is to be expected....

Calculate size of UILabel with different font types

ios,uilabel,uifont,cgrect,cgsize

So basically you want to calculate height of text when you know text width. CGRect rect = [str boundingRectWithSize:CGSizeMake(cellWidth, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil]; Use resulting rect.size the way you want....

Why is boundingRectWithSize wrong when using UIFont preferredFontForTextStyle?

ios8,nsstring,uilabel,uifont

A label adds a little margin round the outside of the text, and you have not allowed for that. If, instead, you use a custom UIView exactly the size of the string rect, you will see that the text fits perfectly: Here's the code I used. In the view controller:...

UIFont extension in SWIFT

ios,swift,uifont

UIFont.fontNamesForFamilyName(familyNames.objectAtIndex(indFamily)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ objectAtIndex, being a Objective-C method that returns id, returns a AnyObject instance in Swift, not a String. You could "cast" that to String. fontNames = NSArray(array: UIFont.fontNamesForFamilyName( familyNames.objectAtIndex(indFamily) as String)) This is how a version with more Swift and less Objective-C would look like: class func listAllFontsOnSystem2(){ let...

How to get monospaced numbers in UILabel on iOS 9

ios,uilabel,uifont,monospace,ios9

What about: let originalFont = UIFont.systemFontOfSize(17) let originalFontDescriptor = originalFont.fontDescriptor() let fontDescriptorFeatureSettings = [ [ UIFontFeatureTypeIdentifierKey: kNumberSpacingType, UIFontFeatureSelectorIdentifierKey: kMonospacedNumbersSelector ] ] let fontDescriptorAttributes = [UIFontDescriptorFeatureSettingsAttribute: fontDescriptorFeatureSettings] let fontDescriptor = originalFontDescriptor.fontDescriptorByAddingAttributes(fontDescriptorAttributes) let font = UIFont(descriptor: fontDescriptor,...

Get height of string with font

ios,uifont

I have decided to simply create a dummy label, set it's text property and set numberOfLines to 0 and say [label sizeToFit] that will allow you to get the frame of the label, which includes the height. It's not an ideal way, but it works. Apparently in iOS 8 there...

Changing font size of attributed text in UITextView takes a lot of time in iOS 6 using Xcode 5

ios,ios6,xcode5,uitextview,uifont

I finally fixed this problem by recreating my attributedtext again and setting it as a new attributedtext to my uitextview.

Font type and color based on device

ios,swift,uifont,uiblureffect

Usually it's done by defining behavior for each specific device. You can find out the device type in runtime: https://gist.github.com/Jaybles/1323251 Example code: UIDeviceHardware *h=[[UIDeviceHardware alloc] init]; if ( [h platformString] isEqualToString:@"iPhone4"] ) { // don't use blur } As for which devices support blur, you can use code from here:...

changing UITableViewCell text font

uitableview,swift,xcode6,uifont,textlabel

You're using the regular font name. To use the bold variation of the font, use this code: cell.textLabel?.font = UIFont(name: "SnellRoundhand-Bold", size: 40) ...

Extension function asking for return type instead of parameter

swift,uifont,swift-extensions

museoSansRounded900 should be a class method as you're trying to call it directly on the UIFont class (which makes it basically a constructor). class func museoSansRounded900(size: CGFloat) -> UIFont ... ...

How can I change the font size in a text view, but not the font style? (light vs. regular) - Swift

swift,fonts,styles,size,uifont

You can do it like. textView.font = UIFont(name: textView.font.fontName, size: 18) Here the font should be as same you defined but you can change the size as you want. If you want to fix the size then and change the name of font then you can use textView.font.pointSize...

Cannot add custom font to Xcode

ios,objective-c,uifont,custom-font

You inadvertently added them to the wrong (Test) Info.plist.

Helvetica Neue Bold Identifier

uifont

HelveticaNeue-Bold is the identifier. Here is a snippet of code you can use to list all the available fonts: NSArray *familyNames = [[NSArray alloc]initWithArray:[UIFont familyNames]]; for (NSString *familyName in familyNames) { NSLog(@"%@", familyName); NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName]; for (NSString *fontName in fontNames) { NSLog(@"\t%@", fontName); } } ...

Not able to set custom fonts in WatchKit

ios,uifont,watchkit,apple-watch

Yes, you can use custom fonts in WatchKit https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/TextandLabels.html...

Font used for Timer in iOS 7's Clock app

ios,core-text,uifont,typography

The slight difference is probably due to some fractional offset of the text itself. The pixels in the two characters look very close to the same, but with different amounts of grey or black. Try placing your Helvetica Neue Ultra Light text 0.5 pixels left or right and 0.5 up...

When i try to apply “Font” to one tableview cell it automatically apply to other cells when scroll tableview

swift,uitableview,fonts,uifont,custom-cell

You can applied bold font on alternative cell like as bellowed way. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let couCell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as UITableViewCell let row = indexPath.row if row == 2 || row == 4 || row == 6 { couCell?.textLabel?.font = UIFont(name: "Helvetica-BoldOblique",...

How to check if a character is supported by a font

ios,objective-c,fonts,uifont,emoji

I finally solve it : - (BOOL)isCharacter:(unichar)character supportedByFont:(UIFont *)aFont { UniChar characters[] = { character }; CGGlyph glyphs[1] = { }; CTFontRef ctFont = CTFontCreateWithName((CFStringRef)aFont.fontName, aFont.pointSize, NULL); BOOL ret = CTFontGetGlyphsForCharacters(ctFont, characters, glyphs, 1); CFRelease(ctFont); return ret; } ...

How to added font image to uilabel

ios,objective-c,uilabel,true-type-fonts,uifont

I'm assuming that you have verified the font is loaded and set onto the label. If not you need to log all of the fonts loaded in the system, check it's there and find the correct font name to pass to UIFont. You need to set the label text to...

changing the value of size in fontWithName has no visible effect

ios,uifont

[UIFont fontWithName:@"HelveticaNeue-Thin" size:14.0]; Your font name is incorrect....