现在的位置: 首页 > 综合 > 正文

IOS:UINavigationBar、navigationItem

2018年02月03日 ⁄ 综合 ⁄ 共 805字 ⁄ 字号 评论关闭

    UINavigationBar* navigation = [[UINavigationBaralloc]
initWithFrame:CGRectMake(100,150,
568, 50)];

    [self.viewaddSubview:navigation];

    

    UINavigationItem* navigationItem = [[UINavigationItemalloc]
init];

    [navigationpushNavigationItem:navigationItem
animated:YES];

    

    UIButton *backButton = [UIButtonbuttonWithType:UIButtonTypeCustom];

    backButton.frame =CGRectMake(0.0,0.0,
55.0, 30.0);

    [backButton setTitle:@"返回"forState:UIControlStateNormal];

    backButton.titleLabel.font = [UIFontsystemFontOfSize:14.0];

    [backButton addTarget:selfaction:@selector(backAction)forControlEvents:UIControlEventTouchUpInside];

   UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItemalloc]
initWithCustomView:backButton];

    temporaryBarButtonItem.style =UIBarButtonItemStylePlain;

    

    navigationItem.leftBarButtonItem = temporaryBarButtonItem;

抱歉!评论已关闭.