Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setBounds in Swift

I'm trying to convert a Objective-C app to Swift but I'm stuck with setBounds. The original code looks like this:

- (void)setBounds:(CGRect)bounds {
    [super setBounds:bounds];

    // code
}

What is the equivalent in Swift? I've tried looking in the documents and google but can't seem to figure it out.

like image 777
Henny Lee Avatar asked Nov 25 '25 10:11

Henny Lee


1 Answers

You need to override bounds:

override var bounds: CGRect{
   didSet{
          //your code here  
   }
}
like image 76
Hamza Ansari Avatar answered Nov 28 '25 00:11

Hamza Ansari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!