Three20中StyleSheet用法随笔(1)

1、创建自己的样式文件

//MyStyleSheet.h

#import <Three20/Three20.h>
#import <Three20Style/TTDefaultStyleSheet.h>
#import <Three20Style/TTDefaultStyleSheet+DragRefreshHeader.h>

@interface MyStyleSheet : TTDefaultStyleSheet 


@end

//MyStyleSheet.m

#import "MyStyleSheet.h"
#import <Three20UI/UIViewAdditions.h>

@implementation MyStyleSheet

- (UIFont*)font {
    return [UIFont fontWithName:@"Arial" size:14];
}

- (UIFont*)tableFont {
    return [UIFont fontWithName:@"Arial" size:14];
}

- (UIFont*)tableHeaderPlainFont {
    return [UIFont fontWithName:@"Arial" size:14];
}

- (UIFont*)tableButtonFont{
    return [UIFont fontWithName:@"Arial" size:14];
}

- (UIFont*)tableTitleFont{
    return [UIFont fontWithName:@"Arial" size:17];
}

- (UIFont*)titleFont {
    return [UIFont fontWithName:@"Arial" size:17];
}

- (UIColor*)tableGroupedBackgroundColor {
    //return RGBCOLOR(224, 221, 203);
    return mainBgByImg;
}

- (UIColor*)tableHeaderTextColor {
    //return [UIColor brownColor];
    return [UIColor blackColor];
}

- (UIColor*)tableHeaderTintColor {
    return RGBCOLOR(224, 221, 203);
}

- (UIColor*)navigationBarTintColor {
    //return RGBCOLOR(100, 128, 108);
    return RGBCOLOR(0, 119, 188);
}

- (UIColor*)toolbarTintColor{
    return RGBCOLOR(0, 119, 188);
}

- (TTStyle*)largeText {
    return [TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:18] next:nil];
}

- (TTStyle*)blueBox {
    return
    [TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:0] next:
     [TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, -5, -4, -6) next:
      [TTShadowStyle styleWithColor:[UIColor grayColor] blur:2 offset:CGSizeMake(1,1) next:
       [TTSolidFillStyle styleWithColor:[UIColor cyanColor] next:
        [TTSolidBorderStyle styleWithColor:[UIColor grayColor] width:1 next:nil]]]]];
    
}

- (TTStyle*)viewInnerShadow {
    return
    [TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:0] next:
     [TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.5) blur:8 offset:CGSizeMake(2, 2) next:
      [TTInsetStyle styleWithInset:UIEdgeInsetsMake(0.25, 0.25, 0.25, 0.25) next:
       [TTSolidFillStyle styleWithColor:[UIColor whiteColor] next:
        [TTInsetStyle styleWithInset:UIEdgeInsetsMake(-0.25, -0.25, -0.25, -0.25) next:
         [TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.5) blur:6 offset:CGSizeMake(1, 1) next:nil]]]]]];
}

- (TTStyle*)launcherButton:(UIControlState)state {
    return
    [TTPartStyle styleWithName:@"image"
                         style:TTSTYLESTATE(launcherButtonImage:, state)
                          next:[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:14]
                                                    color:[UIColor blackColor]
                                          minimumFontSize:14
                                              shadowColor:nil
                                             shadowOffset:CGSizeZero
                                                     next:nil]];
}

- (TTStyle*)blackForwardButton:(UIControlState)state {
    TTShape* shape = [TTRoundedRightArrowShape shapeWithRadius:4.5];
    UIColor* tintColor = RGBCOLOR(0, 119, 188);
    return [TTSTYLESHEET toolbarButtonForState:state shape:shape tintColor:tintColor font:nil];
}

- (TTStyle*)blueToolbarButton:(UIControlState)state {
    TTShape* shape = [TTRoundedRectangleShape shapeWithRadius:4.5];
    UIColor* tintColor = RGBCOLOR(30, 110, 255);
    return [TTSTYLESHEET toolbarButtonForState:state shape:shape tintColor:tintColor font:nil];
}

@end

2、调用样式

1)   #import "StyleSheet.h"

2) 初始化调用的样式类

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [TTStyleSheet setGlobalStyleSheet:[[[MyStyleSheet alloc] init] autorelease]];    //在这里初始化
    }
    return self;
}

3) 使用样式

TTButton  :  TTButton *backBtn = [TTButton buttonWithStyle:@"toolbarBackButton:" title:@"返回"];

TTView *topView = [[TTView alloc] initWithFrame:CGRectMake(0, 0, appFrame.size.width, 80)];
topView.style = [[TTStyleSheet globalStyleSheet] styleWithSelector:@"viewInnerShadow"]; //指定样式名称;
topView.backgroundColor = self.view.backgroundColor;
[self.view addSubview:topView];

   


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值