UIView的子类,不能设置它自己的层。corner radius ?

时间:2021-02-24 21:12:46

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?

为什么我不能设置我自己的图层呢?

2 个解决方案

#1


3  

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/

#2


1  

Have you tried:

你有试过:

self.layer.cornerRadius = 8;

#1


3  

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/

#2


1  

Have you tried:

你有试过:

self.layer.cornerRadius = 8;