How can I get a view's current width and height when using autolayout constraints?

前端 未结 5 2107
难免孤独
难免孤独 2020-11-28 18:00

I\'m not talking about the frame property, because from that you can only get the view\'s size in the xib. I\'m talking about when the view is resized because of its constra

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 18:59

    For those who may still be facing such issues, especially with TableviewCell.

    Just override the method:

    -(void)layoutSubviews
    {
    //your code here like drawing a shadow
    }
    

    In case of UITableViewCell or UICollectionViewCell create a subclass of the cell and override the same method:

    -(void)layoutSubviews
    {
    //your code here like drawing a shadow
    }
    

提交回复
热议问题