垂直偏移UILabel中的文本

时间:2016-11-28 11:27:08

标签: ios xcode swift3

Layout without header background

Layout with header background so you can see its centered

我试图让标题看起来在设计中居中,但由于单元格中的顶部空间,它看起来已经被置于高处。如何让它出现在所有屏幕尺寸上?我担心如果我使用点数偏移它会在大屏幕上偏移太小而在小屏幕上偏移很大?

目前我这样做:

func adjustLayoutToFrame(){
        let screenSize = UIScreen.main.bounds
        let screenHeight = screenSize.height
        let cellHeight = screenHeight / 9
        let headerHeight = cellHeight*2

        weekHeaderLabel.frame.size.height = headerHeight
        print("header height set to:", headerHeight)
        cellHeightForDevice = cellHeight

        //weekHeaderLabel.backgroundColor = .blue

    }

1 个答案:

答案 0 :(得分:0)

不要篡改edgeInset值,而是尝试删除填充,如下所示

转到 - YouStoryboard.storyboard> YourViewController>属性检查器>取消选中 - 调整滚动视图插图。

enter image description here