iOS 导航栏、状态栏

一、修改导航栏及状态栏的透明度

iOS 修改导航栏及状态栏的透明度

二、导航栏返回按钮靠右问题
+(UIBarButtonItem *)itemWithImageName:(NSString *)imageName HighimageName:(NSString *)highimageName  target:(id)target action:(SEL)action
{
    /**导航栏按钮(按钮大小为背景图片的大小)*/
    UIButton * Button=[[UIButton alloc]init];
    /**导航栏按钮(按钮大小大于背景图片的大小,背景图片原图显示、不变形)*/
    [Button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];;
    [Button setImage:[UIImage imageNamed:highimageName] forState:UIControlStateHighlighted];
    //按钮的大小为当前按钮的大小
    //Button.size =CGSizeMake(40, 40);
    Button.frame =CGRectMake(0, 0, 40, 40);
    //向左偏移-10,为了让图片不压缩,必须向右偏移10
    Button.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 10);

    Button.imageView.contentMode=UIViewContentModeCenter;
    [Button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc]initWithCustomView:Button];
    
}

你可能感兴趣的:(iOS 导航栏、状态栏)