KrauseFx / TSMessages

💌 Easy to use and customizable messages/notifications for iOS à la Tweetbot
http://krausefx.com
MIT License
4.87k stars 721 forks source link

modifying font in Swift #280

Open idokleinman opened 8 years ago

idokleinman commented 8 years ago

this does not translate to Swift:

#import <TSMessages/TSMessageView.h>
@implementation TSAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //If you want you can overidde some properties using UIAppearance
    [[TSMessageView appearance] setTitleFont:[UIFont boldSystemFontOfSize:6]];
    [[TSMessageView appearance] setContentFont:[UIFont boldSystemFontOfSize:10]];
     return YES;
}

couldn't set notification font in Swift. Any advice?

gotkaren commented 8 years ago

Hi @idokleinman . I also wanted to translate the implementation to Swift.

I took a look to the Objective-c code and I found out this:

 NSString *fontName = [current valueForKey:@"titleFontName"];
        if (fontName != nil) {
            [self.titleLabel setFont:[UIFont fontWithName:fontName size:fontSize]];
        } else {
            [self.titleLabel setFont:[UIFont boldSystemFontOfSize:fontSize]];
        }

So I just added the parameter titleFontName to the TSMessagesDefaultDesign file and it worked for me. The name for the Subtitle text font is contentFontName

screen shot 2016-08-17 at 11 59 07 am

It works just like the other parameters do.