반응형

// StyleSheet.h

#import <Foundation/Foundation.h>

typedef enum : int
{
    LabelTypeName = 0,
    LabelTypeBirthdayDate,
    LabelTypeDaysUntilBirthday,
    LabelTypeDaysUntilBirthdaySubText,
    LabelTypeLarge
}LabelType;

@interface StyleSheet : NSObject

+ (void)styleLabel:(UILabel *)label withtype:(LabelType)labelType;
+ (void)styleRoundCorneredView:(UIView *)view;

+ (void)initStyles;
+ (void)styleTextView:(UITextView *)textView;

@end


// StyleSheet.m

#import "StyleSheet.h"
#import <QuartzCore/QuartzCore.h>
#import "BlueButton.h"
#import "RedButton.h"

#define kFontLightOnDarkTextColor [UIColor colorWithRed:255.0/255 green:251.0/255 blue:218.0/255 alpha:1.0]
#define kFontDarkOnLightTextColor [UIColor colorWithRed:1.0/255 green:1.0/255 blue:1.0/255 alpha:1.0]

#define kFontNavigationTextColor [UIColor colorWithRed:106.f/255.f green:62.f/255.f blue:39.f/255.f alpha:1.f]
#define kFontNavigationDisabledTextColor [UIColor colorWithRed:106.f/255.f green:62.f/255.f blue:39.f/255.f alpha:0.6f]
#define kNavigationButtonBackgroundColor [UIColor colorWithRed:255.f/255.f green:245.f/255.f blue:225.f/255.f alpha:1.f]
#define kToolbarButtonBackgroundColor [UIColor colorWithRed:39.f/255.f green:17.f/255.f blue:5.f/255 alpha:1.f]
#define kLargeButtonTextColor [UIColor whiteColor]

#define kFontNavigation [UIFont fontWithName:@"HelveticaNeue-Bold" size:18.f]
#define kFontName [UIFont fontWithName:@"HelveticaNeue-Bold" size:15.f]
#define kFontBirthdayDate [UIFont fontWithName:@"HelveticaNeue" size:13.f]
#define kFontDaysUntilBirthday [UIFont fontWithName:@"HelveticaNeue-Bold" size:25.f]
#define kFontDaysUntilBirthdaySubText [UIFont fontWithName:@"HelveticaNeue" size:9.f]
#define kFontLarge [UIFont fontWithName:@"HelveticaNeue-Bold" size:17.f]
#define kFontButton [UIFont fontWithName:@"HelveticaNeue-Bold" size:30.f]
#define kFontNotes [UIFont fontWithName:@"HelveticaNeue" size:16.f]
#define kFontPicPhoto [UIFont fontWithName:@"HelveticaNeue-Bold" size:12.f]
#define kFontDropShadowColor [UIColor colorWithRed:1.0/255 green:1.0/255 blue:1.0/255 alpha:0.75]

@implementation StyleSheet

+(void)styleLabel:(UILabel *)label withtype:(LabelType)labelType
{
    switch (labelType)
    {
        case LabelTypeName:
            label.font = kFontName;
            label.layer.shadowColor = kFontDropShadowColor.CGColor;
            label.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
            label.layer.shadowRadius = 0.0f;
            label.layer.masksToBounds = NO;
            label.textColor = kFontLightOnDarkTextColor;
            break;
        case LabelTypeBirthdayDate:
            label.font = kFontBirthdayDate;
            label.textColor = kFontLightOnDarkTextColor;
            break;
        case LabelTypeDaysUntilBirthday:
            label.font = kFontDaysUntilBirthday;
            label.textColor = kFontDarkOnLightTextColor;
            break;
        case LabelTypeDaysUntilBirthdaySubText:
            label.font = kFontDaysUntilBirthdaySubText;
            label.textColor = kFontDarkOnLightTextColor;
            break;
        case LabelTypeLarge:
            label.textColor = kFontLightOnDarkTextColor;
            label.layer.shadowColor = kFontDropShadowColor.CGColor;
            label.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
            label.layer.shadowRadius = 0.0f;
            label.layer.masksToBounds = NO;
            break;
           
           
        default:
            label.textColor = kFontLightOnDarkTextColor;
            break;
    }
}

+ (void)styleRoundCorneredView:(UIView *)view
{
    view.layer.cornerRadius = 4.f;
    view.layer.masksToBounds = YES;
    view.clipsToBounds = YES;
}

+ (void)initStyles
{
    // 내비게이션 바.
    NSDictionary *titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:kFontNavigationTextColor, UITextAttributeTextColor,
                                         [UIColor whiteColor], UITextAttributeTextShadowColor,
                                         [NSValue valueWithUIOffset:UIOffsetMake(0, 2)], UITextAttributeTextShadowOffset,
                                         kFontNavigation, UITextAttributeFont, nil];
   
    [[UINavigationBar appearance] setTitleTextAttributes:titleTextAttributes];
   
    //  배경 이미지로 설정.
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigation-bar-background.png"] forBarMetrics:UIBarMetricsDefault];
   
    NSDictionary *barButtonItemTextAttributes;
   
    // 내비게이션 버튼.
   
    // 내비게이션 버튼 배경의 색상.
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:kNavigationButtonBackgroundColor];
   
    barButtonItemTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                   kFontNavigationTextColor, UITextAttributeTextColor,
                                   [UIColor whiteColor], UITextAttributeTextShadowColor,
                                   [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil];
   
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:barButtonItemTextAttributes forState:UIControlStateNormal];
   
    NSDictionary *disabledBarButtonItemTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                                         kFontNavigationDisabledTextColor, UITextAttributeTextColor,
                                                         [UIColor whiteColor], UITextAttributeTextShadowColor,
                                                         [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil];
   
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:disabledBarButtonItemTextAttributes forState:UIControlStateDisabled];
   
    // 툴바.
    // 툴바  배경 이미지.
    [[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"tool-bar-background.png"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
   
    // 툴바 버튼
    // 툴바 버튼에 어두운 배경 적용.
    // 툴바 버튼 배경색.
    [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTintColor:kToolbarButtonBackgroundColor];
   
    // UIBarButtonItem에 흰색 텍스트 적용.
    barButtonItemTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor, nil];
   
    [[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil] setTitleTextAttributes:barButtonItemTextAttributes forState:UIControlStateNormal];
   
    // 버튼.
    [[BRBlueButton appearance] setBackgroundImage:[UIImage imageNamed:@"button-blue.png"] forState:UIControlStateNormal];
    [[BRBlueButton appearance] setTitleColor:kLargeButtonTextColor forState:UIControlStateNormal];
   
    [[BRRedButton appearance] setBackgroundImage:[UIImage imageNamed:@"button-red.png"] forState:UIControlStateNormal];
    [[BRRedButton appearance] setTitleColor:kLargeButtonTextColor forState:UIControlStateNormal];
   
    [[BRRedButton appearance] setFont:kFontLarge];
   
    // 테이블 뷰.
    [[UITableView appearance] setBackgroundColor:[UIColor clearColor]];
    [[UITableViewCell appearance] setSelectionStyle:UITableViewCellSelectionStyleNone];
    [[UITableView appearance] setSeparatorStyle:UITableViewCellSeparatorStyleNone];
   
}

+ (void)styleTextView:(UITextView *)textView
{
    textView.backgroundColor = [UIColor clearColor];
    textView.font = kFontNotes;
    textView.textColor = kFontLightOnDarkTextColor;
    textView.layer.shadowColor = kFontDropShadowColor.CGColor;
    textView.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
    textView.layer.shadowRadius = 0.0f;
    textView.layer.masksToBounds = NO;
}

@end


반응형

'IPHONE' 카테고리의 다른 글

NSUserDefaults 사용하기.  (0) 2014.02.18
배열 정렬하기.  (0) 2014.02.17
prepareForSegue 사용하기.  (0) 2014.02.12
아이콘에 대한 설명  (0) 2014.02.08
iOS 6에서 오토 레이아웃 시작하기. 파트 2  (0) 2014.02.08
Posted by 컴스터
,