zoukankan      html  css  js  c++  java
  • iOS

    1.设置导航栏标题

    self.title = @"dylan_李伟宾";

    2.设置导航栏样式

    设置方法:

    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];

    UIBarStyle的样式:

    typedef NS_ENUM(NSInteger, UIBarStyle) {
        UIBarStyleDefault          = 0,
        UIBarStyleBlack            = 1,
    
        UIBarStyleBlackOpaque      = 1, // Deprecated. Use UIBarStyleBlack
        UIBarStyleBlackTranslucent = 2, // Deprecated. Use UIBarStyleBlack and set the translucent property to YES
    };

    UIBarStyleDefault是默认样式,UIBarStyleBlack是黑色不透明。UIBarStyleBlackOpaqueUIBarStyleBlackTranslucent这两个已经废弃了。

    假设想设置导航栏透明,能够加上以下这句代码:

    self.navigationController.navigationBar.translucent = YES;

    3.改动返回buttontitle

    self.navigationItem.title = @"test";

    4.隐藏返回buttontitle

    比較笨的方法是:

    self.navigationItem.title = @"";

    还能够这样设置:

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

    5.设置leftBarButtonItem

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
    
    - (void)back:(id)sender
    {
        [self.navigationController popViewControllerAnimated:YES];
    }

    6.左滑返回手势失效了怎么办

    假设按上一步设置leftBarButtonItem之后,左滑返回手势就会失效。

    设置一下UIGestureRecognizerDelegate代理就可以:

    self.navigationController.interactivePopGestureRecognizer.delegate = self;
  • 相关阅读:
    bzoj1015题解
    bzoj1013题解
    bzoj1012题解
    bzoj1011题解
    bzoj1010题解
    BZOJ4561: [JLoi2016]圆的异或并 计算几何+treap
    后缀数组 hash求LCP BZOJ 4310: 跳蚤
    prufer BZOJ1211: [HNOI2004]树的计数
    网络流
    BZOJ3160【万径人踪灭】 【FFT】
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7273595.html
Copyright © 2011-2022 走看看