How to align UILabel text from bottom?

后端 未结 10 1505
盖世英雄少女心
盖世英雄少女心 2021-02-03 19:08

How the UILabel can be aligned from bottom. Let say, my label can hold three line of text.If the input text is single line, then this line should come bottom of the

10条回答
  •  独厮守ぢ
    2021-02-03 20:04

    1. use autoLayout)
    textLabel.numberOfLines = 0
    textLabel.textAlignment = .center
    
    textLabel.topAnchor.constraint(greaterThanOrEqualTo: sView.topAnchor).isActive = true
    textLabel.leadingAnchor.constraint(equalTo: sView.leadingAnchor).isActive = true
    textLabel.trailingAnchor.constraint(equalTo: sView.trailingAnchor).isActive = true
    textLabel.bottomAnchor.constraint(equalTo: sView.bottomAnchor).isActive = true
    

提交回复
热议问题