Como aumentar programaticamente a altura do UIView com Swift
Dentro do IB, tenho um viewController com um segmentedControl e 2 containerViews. Em cada containerView, tenho um tableView. De cada tableView, pressiono um detailView. Meu layout automático está no IB.
Depois de escolher um segmento, vejo o tableView correspondente, escolho uma célula e o detailView correto é pressionado em cena.
O problema ocorre quando o detailView é pressionado no segmentedControl ainda está visível. Decidi ocultar o segmentedControl que funciona, mas há um grande espaço vazio lá. Tentei aumentar programaticamente o tamanho do modo de exibição detailView, mas ele não está se expandindo. Pelo que li, é porque criei as restrições iniciais nos storyboards.
Como obter programaticamente a exibição do detailView para expandir?
código:
DetailViewController: UIViewController{
override func viewDidLoad() {
super.viewDidLoad()
//this isn't increasing the view's size
self.view.frame.size.height += 20.0
//doesn't work. I get an error on the last argument
self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height += 20.0)
//doesn't work. I get an error on the last argument
self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.size.height += 20.0)
}
}
Erros:
//Error for the last argument- height: *self.view.frame.height += 20.0*
self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height += 20.0)
O lado esquerdo do operador de mutação não é mutável: 'height' é uma propriedade get-only
//Error for the last argument- *self.view.frame.size.height += 20.0*:
self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.size.height += 20.0)
Não é possível invocar o inicializador para o tipo 'CGRect' com uma lista de argumentos do tipo '(x: Int, y: Int, largura: CGFloat, height: ())'