How to create a NSImageView with a rounded corner?

烂漫一生 提交于 2020-01-02 02:35:17

问题


Currently now i want to create a round corner NSImageView,i am a newb,how to ?


回答1:


I don't know if this will work so please try it and we'll cross our fingers. On the iPhone you can use the CALayer of any UIView (the NSView counterpart in iOS) to get rounded corners. Based on the reference docs it appears that NSView supports this but again you'll have to try it. Please let me know if it works.

NSImageView *view = your view;

[view setWantsLayer: YES];  // edit: enable the layer for the view.  Thanks omz

view.layer.borderWidth = 1.0;
view.layer.cornerRadius = 8.0;
view.layer.masksToBounds = YES;

You can also modify the borderWidth and borderColor properties.



来源:https://stackoverflow.com/questions/4687493/how-to-create-a-nsimageview-with-a-rounded-corner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!