如何创建像Facebook消息一样的循环UIView.
它只是一个圆角的矩形还是一个中心有圆形图像的矩形?
这是图像视图:
这是自定义单元类的initWithStyle代码:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
[self.userImage setBackgroundColor:[UIColor orangeColor]];
[self.userImage.layer setCornerRadius:32.0f];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
但我仍然得到一个矩形的图像视图.
您必须修改视图图层上的cornerRadius属性.为了得到一个圆,你应该指定一个角半径等于视图高度/宽度的一半.这是一个基本的例子:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 120.0f, 120.0f)];
[view setBackgroundColor:[UIColor orangeColor]];
[view.layer setCornerRadius:60.0f];
[self.view addSubview:view];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1516 次 |
| 最近记录: |