【问题标题】:Xcode / Swift | Add TopBorder to TabBarXcode / 斯威夫特 |将 TopBorder 添加到 TabBar
【发布时间】:2019-04-07 15:26:11
【问题描述】:

到目前为止,基本上我得到的是一个带有自定义图标的基本 TabBarController。现在我想尽可能简单地在 TabBar 的顶部添加带有特定 UIColor 的边框。我怎么做? My tabBar so far

【问题讨论】:

    标签: swift xcode uitabbarcontroller tabbar


    【解决方案1】:

    配置标签栏如下:-

    // Create a new layer which is the width of the device and with a heigh
    // of 0.5px.
    CALayer *topBorder = [CALayer layer];
    topBorder.frame = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 0.5f);
    
    // Set the background colour of the new layer to the colour you wish to
    // use for the border.
    topBorder.backgroundColor = [[UIColor blueColor] CGColor];
    
    // Add the later to the tab bar's existing layer
    [self.tabBar.layer addSublayer:topBorder];
    self.tabBar.clipsToBounds = YES;
    

    要么将你的标签栏子类化并将其写在那里,要么将其写为全局函数。

    【讨论】:

      猜你喜欢
      • 2017-07-22
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-28
      • 2021-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多