调整UITabBar的大小(图片)

时间:2016-07-03 02:58:18

标签: swift resize uitabbar

我最近将我的TabBar图像更改为我自己制作的栏(请参阅照片以供参考)。当我在Iphone 5s模拟器中运行它时,它的尺寸非常合适。但是当我在Iphone 6上运行它时,它不会自动调整大小,所以它停在Iphone 5停止的地方(图2)。如何让TabBar图像调整大小?

更新

    override func viewDidLoad() {
    super.viewDidLoad()


     UITabBar.appearance().translucent = true
    UITabBar.appearance().tintColor = UIColor.whiteColor()




    UITabBar.appearance().selectionIndicatorImage = UIImage().makeImageWithColorAndSize(UIColor(red: 127.0 / 255.0, green: 217.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0), size: CGSizeMake(tabBar.frame.width/5, tabBar.frame.height))


    UITabBar.appearance().barTintColor = UIColor.whiteColor()

    UITabBar.appearance().backgroundImage = UIImage(named:"officialbar")



}

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

您熟悉自动布局和约束吗?您无需打开每个模拟器即可查看它在不同设备上的外观。

您可以打开Storyboard - >点击助理编辑器enter image description here - >现在,在#>>;手册" enter image description here的上方点击"预览" enter image description here

现在,您可以更轻松地使用约束进行处理,并在更改后立即查看不同屏幕尺寸的外观。