I have an iOS app that uses the code below. I am now creating the app for Mac OS X and would like the same effect however I do not seem to be able to use clipsToBounds. What should I be using?
I have the rest of the code working on the Mac, just not that part.
Thanks
var myImage = UIImage()
let view = UIImageView(frame: CGRectMake(0, 0, 100, 100))
view.contentMode = UIViewContentMode.ScaleAspectFill
view.layer.opacity = opacity
view.layer.cornerRadius = cornerRadius
view.clipsToBounds = true
view.image = self.myImage
self.mainView.addSubview(view)
You should have showed your Cocoa code and what you had tried.
In any case, Cocoa views clip to their bounds by default. If you don't want the image to be scaled, set the imageScaling property to NSImageScaleNone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With