在自定义视图中找不到-setCornerRadius [英] -setCornerRadius not found in custom view

查看:199
本文介绍了在自定义视图中找不到-setCornerRadius的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个自定义的uitableviewcell类,在这个单元格中,我有一个方形标签。我想用标签(dateBox)的四个角落:

I am making a custom uitableviewcell class and inside this cell I have a square label. I would like to round the corners of the label(dateBox) using this:

[dateBox.layer setCornerRadius:4.0f];
[dateBox.layer setMasksToBounds:YES];



我这样做是其他类,它工作正常,但由于某些原因在uitableviewcell子类,得到警告setCornerRadius method not found。

I do this is other classes and it works fine, but for some reason in the uitableviewcell subclass, I get the warning "setCornerRadius method not found". Does anyone know why this might be?

推荐答案

您需要导入QuartzCore并确保它是您项目中包含的框架。

You need to import QuartzCore and make sure it is an included framework in your project.

#import <QuartzCore/QuartzCore.h>

#import <QuartzCore/CALayer.h>

这篇关于在自定义视图中找不到-setCornerRadius的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆