navigationBar中左右Item


    /*
     // 系统箭头样式
     UIBarButtonSystemItemPlay

     */
    
    UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(rightButton)];
    
    self.navigationItem.rightBarButtonItem = rightBtn;php


    // right itme (变相让按钮靠右)
    UIButton * rightItemButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 40)];
    
    // 设置 宽高 (需倒入工具类)
    //rightItemButton = CGSizeMake(100, 40);
    
    /*
     
     // 加上边框
     [rightItemButton.layer setBorderWidth:1.0f];
     
     // 圆角
     [rightItemButton.layer setCornerRadius:4.0f];
     
     // 边框颜色
     [rightItemButton.layer setBorderColor:[UIColor blackColor].CGColor];
     
     */
    
    [rightItemButton setTitle:@"下一步" forState:UIControlStateNormal];
    
    // 字体大小
    rightItemButton.titleLabel.font = [UIFont systemFontOfSize:20];
    
    // 颜色
    [rightItemButton setTitleColor:[UIColor colorWithRed:0.000 green:0.431 blue:0.427 alpha:1.000] forState:UIControlStateNormal];
    
    // 居中
    [rightItemButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
    
    // 添加点击事件
    [rightItemButton addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    // 第一次见
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:rightItemButton];
    
    // 状态 做用不明
    //[rightButton setStyle:UIBarButtonItemStyleDone];
    
    // 设置 右边time 为
    [self.navigationItem setRightBarButtonItem:rightButton];

html


学自:http://www.cocoachina.com/bbs/read.php?tid-298084.html
ide

相关文章
相关标签/搜索