IOS中自定义navigationItem的按钮

//创建homeButtonView层
        UIView *homeButtonView = [[[UIView alloc]initWithFrame:CGRectMake(0, 0, 55, 40)]autorelease];
        UIImageView *homeButtonImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 55, 40)];
        homeButtonImageView.image = [UIImage imageNamed:@"nav_btn_home_ipad.png"];
        UIButton *homeButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 55, 40)];
        homeButton.backgroundColor = [UIColor clearColor];
        [homeButton addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
        [homeButtonView addSubview:homeButtonImageView];
        [homeButtonView addSubview:homeButton];
        [homeButton release];
        [homeButtonImageView release];
        
        //创建home按钮
        UIBarButtonItem *homeButtonItem = [[UIBarButtonItem alloc]initWithCustomView:homeButtonView];
        self.navigationItem.leftBarButtonItem=homeButtonItem;
        [homeButtonItem release];


你可能感兴趣的:(ios,action,UIView)