QQ空間HD(5)-添加左側功能表列內容

來源:互聯網
上載者:User

標籤:左側菜單   instance   gre   orm   screen   layer   hid   sub   sys   

DJIconView.m

#import "DJIconView.h"@implementation DJIconView- (instancetype)initWithFrame:(CGRect)frame {    if (self = [super initWithFrame:frame]) {        //        self.backgroundColor = [UIColor redColor];        self.imageView.layer.cornerRadius = 5;        [self setImage:[UIImage imageNamed:@"yongdaimi"] forState:UIControlStateNormal];        [self setTitle:@"yongdaimi" forState:UIControlStateNormal];        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];        self.titleLabel.font = [UIFont systemFontOfSize:18];        self.titleLabel.textAlignment = NSTextAlignmentCenter;            }    return self;}- (void)layoutSubviews {    [super layoutSubviews];        if (DJLandscape) { // 橫屏                /* imageView */        self.imageView.width = self.width;        self.imageView.height = self.imageView.width;        self.imageView.x = 0;        self.imageView.y = 0;                /* titleLabel */        self.titleLabel.hidden = NO;        self.titleLabel.width = self.width;        self.titleLabel.height = 40;        self.titleLabel.x = 0;        self.titleLabel.y = self.imageView.height;            } else { // 豎屏                /*imageView*/        self.imageView.width = self.width;        self.imageView.height = self.imageView.width;        self.imageView.x = 0;        self.imageView.y = 0;                /*titleLabel*/        self.titleLabel.hidden = YES;            }}@end

DJTabBar.m

#import "DJTabBar.h"@implementation DJTabBar- (instancetype)initWithFrame:(CGRect)frame {    if (self = [super initWithFrame:frame]) {        //        self.backgroundColor = [UIColor greenColor];                [self setupBtnImage:@"tab_bar_feed_icon" title:@"全部動態"];        [self setupBtnImage:@"tab_bar_passive_feed_icon" title:@"與我相關"];        [self setupBtnImage:@"tab_bar_pic_wall_icon" title:@"照片檣"];        [self setupBtnImage:@"tab_bar_e_album_icon" title:@"電子相框"];        [self setupBtnImage:@"tab_bar_friend_icon" title:@"好友"];        [self setupBtnImage:@"tab_bar_e_more_icon" title:@"更多"];                    }    return self;}- (void)setupBtnImage:(NSString *)imageName title:(NSString *)title {        UIButton *btn = [[UIButton alloc] init];    // 設定按鈕內容靠左對齊    btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;    // 設定左填充    btn.contentEdgeInsets = UIEdgeInsetsMake(0, 30, 0, 0);    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];    btn.titleEdgeInsets = UIEdgeInsetsMake(0, 40, 0, 0);        [btn setTitle:title forState:UIControlStateNormal];    [btn setBackgroundImage:[UIImage imageNamed:@"tabbar_separate_selected_bg"] forState:UIControlStateDisabled];        [self addSubview:btn];}- (void)layoutSubviews {    [super layoutSubviews];     NSUInteger count = self.subviews.count;        if (DJLandscape) { // 橫屏        for (int i = 0; i < count; i++) {            UIButton *btn = self.subviews[i];            btn.width = self.width;            btn.height = self.width / 3;            btn.x = 0;            btn.y = i * btn.height;        }    } else {        for (int i = 0; i < count; i++) {            UIButton *btn = self.subviews[i];            btn.width = self.width;            btn.height = btn.width;            btn.x = 0;            btn.y = i * btn.height;        }    }}@end

QzoneHD.pch

// 橫屏#define DJLandscape ([UIScreen mainScreen].bounds.size.width == 1024)// 豎屏#define DJPortrait ([UIScreen mainScreen].bounds.size.width == 768)

最終效果:

橫屏:

豎屏:

 

QQ空間HD(5)-添加左側功能表列內容

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.