zoukankan      html  css  js  c++  java
  • 自定义UINavgationBar 方法二(原创)

    CustomNavController.h

    //  Created by suruiqiang on 8/3/10.
    //  Copyright 2010 __MyCompanyName__. All rights reserved.
    //
    #pragma once
    #import <UIKit/UIKit.h>
    @interface UINavigationBar (UINavigationBarCategory) 
    UIImageView *bg;
    -(UINavigationBar*)setBackgroundImage:(UIImage*)image;
    - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
    @end
    
    
    

    CustomNavController.m

    #import "CustomerNavBarController.h"
    
    
    @implementation UINavigationBar (UINavigationBarCategory)
    -(UINavigationBar*)setBackgroundImage:(UIImage*)image
    {
    	UINavigationBar *NavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
        if(image == nil) return NavBar;
        bg = [[UIImageView alloc]initWithImage:image];
        bg.frame = CGRectMake(0.f, 0.f, self.frame.size.width, self.frame.size.height);
        [NavBar addSubview:bg];
        [NavBar sendSubviewToBack:bg];
        [bg release];
    	return NavBar;
    }
    
    - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
    {
        [super insertSubview:view atIndex:index];
        [self sendSubviewToBack:bg];
    }
    @end
    
    

     在需要调用的地方添加如下代码:

    - (void)viewDidLoad {
        [super viewDidLoad];
       [[self.navigationController navigationBar] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground.png"]];
    
    //在下面添加你自己的功能代码
    ***********
    }
    
  • 相关阅读:
    802.11协议网文转载
    三角函数公式大全
    IEEE 802.11ac Standard
    FPGA设计如何进行面积优化
    直流偏差消除
    I/Q不平衡补偿
    WiFi6剩余频偏的影响
    SQL SERVER 调优等待类型
    Nginx
    fatal: HttpRequestException encountered解决方法
  • 原文地址:https://www.cnblogs.com/moshengren/p/1855202.html
Copyright © 2011-2022 走看看