Showing posts with label COCOA. Show all posts
Showing posts with label COCOA. Show all posts

Thursday, November 26, 2015

UIFont: SF UI Display. WHY U DO THIS?

Hello, 

So today I'll post about a 1 hour hell I went through trying to handle the "SF UI Display" as a font for a new app I'm working on.











This is a pure Swift project, so as this is my first time messing around it I obviously thought it was some kind of idiodicy of my part, so, as a good boy scout that I am tried:
  1. Converting the OTF to a TTF
  2. Redownloading the OTF and converting it again (never know when you could actually corrupt a file)
  3. Use the OTF (I normally use TTF, if I'm not mistaken TTF was the only supported font type on Cocos2D 1.X, so it kind of became a standard for me too as I started with Cocos - you can get a look on some of my awesome Cocos2D projects, such as Hungry Frog or OldSchool Brix)
  4. Thought that I had dome some nasty shit on the Extension Class I coded (that I was totally hyped about because of the OptionSetType that I've build)
  5. Prayed to Jesus and asked for a Code-Miracle




 So a few minutes after option 5 I had the brilliant idea! I just raged on my designer partner and he asked me a few questions and after that I put my poor excuse for a brain to work again. Went to iosfonts.com and check out if it was actually a system font and it wasn't.

But right at that moment my designer suggest to drop it and use Helvetica Neue so I when searched the font on the site and it was like: "HelveticaNeue-'Specific_Type'". So that light bulb just shined on top of my head and I took a shot and it worked. 

"SFUIDisplay-'Specific_Type'".

So whats the what's the shitter here? Normally, for custom fonts we see it's name one the Font Book and go with it. So that's that. I've been betrayed by the Font Book.

Wrong: UIFont(name: "SF UI Display Bold", size: size)!
Corrent: UIFont(name: "SFUIDisplay-Bold", size: size)!

Cheers

Friday, November 25, 2011

Objective-C/Cocoa: Star Rating Class

Hi breathers,


How's it all going?
It's been a time since i posted, so here's some nice stuff.


Know all those games that rate you after the match(e.g. Angry Birds) with the star system-thing, so i made on very simple so you just need to copy and paste on your project.


Download: StarRate Class (WARNING: Very Huge Dowload - 3K)


Probably you'll would like to add other sizes of banners, so just feel free to use the class as you want.


Oh, yeah! One last thing. I know this is a stupid comment, but remember you're not going to use it directly on the  "-(void)viewDidLoad". Normally you'll use it when the match is ended and on the "level" boxes to display the last rate the player had on that match/level.


After you import the code to your project you have to do this:



#import <UIKit/UIKit.h>

#import "StarRate.h"



@interface StarTestViewController : UIViewController{
    StarRate *_stars;
}

@end


#import "StarTestViewController.h"





@implementation StarTestViewController


-(void)createStars{
    _stars = [[StarRate alloc]init];

    //THIS setBackgroundColor YOU CAN ADD TO THE CLASS I UPLOADED FOR YOU
    //ON THE -(void)startUp METHOD
    [_stars setBackgroundColor:[UIColor clearColor]];
    [_stars setupInterfaceTheWayIWantWithType:STARBANNER_250X50 andRate:2];
    [_stars setCenter:CGPointMake(160, 240)];
    [self.view addSubview:_stars];
}


-(void)viewDidLoad{
    [self createStars];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [super viewDidLoad];
}

(...)


@end






As you can see, i didn't use InterfaceBuilder, i'm kind of on strike with him, so fell free to use InterfaceBuilder if you want, you just need to remember how to inherit a normal UIView to StareRate.

If you need help, just go to the Contact Section and let me know.
Live long and prosper.


Tweet