简体   繁体   English

UIView的子类,不能设置它自己的layer.cornerRadius?

[英]Subclass of UIView, can't set it's own layer.cornerRadius?

I have subclassed UIVIew to make my custom view.我已经将 UIVIew 子类化来制作我的自定义视图。

-(UIMyMessageView*)init:(NSString*)withMessage
 {
   [super initWithFrame:messageFrame];

   // I Would like to do : 
   self->layer.cornerRadius = 8; // This doesn't compile
 }

Why can't I set my own layer?为什么我不能设置自己的图层?

include QuartzCore Framework包括 QuartzCore 框架

#import <QuartzCore/QuartzCore.h>

Also include this framework in your project.还将此框架包含在您的项目中。

http://meandmark.com/blog/2011/03/xcode-4-adding-a-framework-to-your-project/ http://meandmark.com/blog/2011/03/xcode-4-adding-a-framework-to-your-project/

你有没有尝试过:

self.layer.cornerRadius = 8;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM