Search code examples
iosswiftuitableviewuilabelios9

how to set uilabel height to 0. or uitbleviewcell height to 0?


I have a page like this all values are in UIlabel

Now if I got any value nil I hide that label

Problem :

But when I hide that label it is showing blank space

showing blank space

here is mycode::

 let dic = finalcarexpense.objectAtIndex(indexPath.row) as! NSDictionary
    if lastcruisebool == true
    {
        cell.lblcruisecontroll.text = (dic["cruise_control"] as? String)!
    }
    else
    {

        cell.lblcruisecontroll.hidden = true
        cell.placecruisecontrol.hidden = true
    }



    if lastremotebool == true
    {
        cell.lblremotecentrallocking.text = (dic["remote_central_locking"] as? String)!
    }
    else
    {
        cell.lblremotecentrallocking.hidden = true
        cell.placeremotecentrallocking.hidden = true
    }


    if lastacbool == true
    {
        cell.lblairconditioning.text = (dic["air_conditioning"] as? String)!
    }
    else
    {
        cell.lblairconditioning.hidden = true
        cell.placeac.hidden = true
    }


    if lastbluetoothbool == true
    {
        cell.lblbluetooth.text = (dic["bluetooth"] as? String)!
    }
    else
    {
        cell.lblbluetooth.hidden = true
        cell.placebluetooth.hidden = true
    }


    if lastradiocdbool == true
    {
        cell.lblradiocd.text = (dic["radio_cd"] as? String)!
    }
    else
    {

        cell.lblradiocd.hidden = true
        cell.placeradiocd.hidden = true
    }


    if lastpowerbool == true
    {
        cell.lblpowersteering.text = (dic["power_steering"] as? String)!
    }
    else
    {
        cell.lblpowersteering.hidden = true
    }

so is there any solution like should i set UILabel hieght 0?? or should i do this with using UITableViewCell??


Solution

  • You can give uilabel height constraint and can set to 0 at running time. as well you can set it frame to 0 so it will be invisible Thanks