Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSImageView ClipsToBounds

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)
like image 720
Tom Coomer Avatar asked Dec 03 '25 12:12

Tom Coomer


1 Answers

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.

like image 84
Ken Thomases Avatar answered Dec 06 '25 06:12

Ken Thomases



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!