I know how clipsToBounds
works. Or... at least, I thought I did.
Given the following Swift code:
class ViewController: UIViewController {
@IBOutlet weak var redView: UIView!
@IBOutlet weak var blueView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
self.redView.clipsToBounds = false
self.blueView.clipsToBounds = true
}
}
I get the following results:
(with apologies to anyone who is color blind, the top box is red, the bottom box is blue... they are hooked up correctly in interface builder)
Meanwhile, given the following, very equivalent, Objective-C code:
@interface ObjcController()
@property (weak, nonatomic) IBOutlet UIView *redView;
@property (weak, nonatomic) IBOutlet UIView *blueView;
@end
@implementation ObjcController
- (void)viewDidLoad {
[super viewDidLoad];
self.redView.clipsToBounds = NO;
self.blueView.clipsToBounds = YES;
}
@end
I get the following, very opposite, results:
(with the same apologies to anyone who is colorblind, once again, the top box is red, the bottom box is blue, and they're still hooked up in the same way as the Swift implementation was hooked up)
Am I overlooking something very obvious? Or is this a Swift bug? I'm using the same IB file and just changing the view controller's class (and hooking the buttons back up).
For verification that I hooked up the views correctly: