在UIView Swift重新定位UILabel

时间:2016-09-08 09:48:45

标签: ios swift uiview uilabel

我有四个UILabel以编程方式添加到UIView,并且需要根据if条件隐藏每个UILabel

此外,

  1. 隐藏UILabel后,根据隐藏的UIView高度降低UILabel's的高度。

  2. 在每个UILabels转为隐藏状态后,重新定位剩余的UIView以适应UILabel

  3. 我有以下可与之分享的代码 -

    if alphaChars != [] {       //my if condition   
          lettersValidation.removeFromSuperview()     //removing one UILabel
              
          if(alphaCharBool == false){
              tipsViewSection.frame.size.height = tipsViewSection.frame.size.height - 100       //decreased height of the UIView
              alphaCharBool = true
             }
                
          }
          else {
             self.tipsViewSection.addSubview(lettersValidation)     //add UILabel back to the UIView because if condition failed
              alphaCharBool = true
                
          }
    }
    

    同样,我正在为其他UILabels实现相同的结构。有人可以帮助改进这段代码,以满足我在问题开头提到的条件吗?

0 个答案:

没有答案