Ios 如何创建类似Facebook的循环uiview消息

Ios 如何创建类似Facebook的循环uiview消息,ios,uiview,Ios,Uiview,如何创建类似Facebook的循环UIView消息 它只是一个圆角矩形还是一个中心有圆形图像的矩形 以下是图像视图: 下面是自定义单元格类的initWithStyle代码: - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier

如何创建类似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;
}

但是我仍然得到一个矩形的imageview。

您必须修改视图图层上的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];

必须修改视图图层上的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];

只需像这样使用clipToBound:

[cell.yourImage.layer setBorderWidth:2.0f];
[cell.yourImage.layer setBorderColor:[[UIColor blackColor] CGColor]];
[cell.yourImage.layer setShadowRadius:5.0];
[cell.yourImage.layer setShadowOpacity:0.5];
[cell.yourImage.layer setShadowOffset:CGSizeMake(1.0, 0.0)];
[cell.yourImage.layer setShadowColor:[[UIColor blackColor] CGColor]];
[cell.yourImage.layer setCornerRadius:10.0];
cell.yourImage.clipsToBounds = YES;

希望它有帮助

只需像这样使用clipToBound:

[cell.yourImage.layer setBorderWidth:2.0f];
[cell.yourImage.layer setBorderColor:[[UIColor blackColor] CGColor]];
[cell.yourImage.layer setShadowRadius:5.0];
[cell.yourImage.layer setShadowOpacity:0.5];
[cell.yourImage.layer setShadowOffset:CGSizeMake(1.0, 0.0)];
[cell.yourImage.layer setShadowColor:[[UIColor blackColor] CGColor]];
[cell.yourImage.layer setCornerRadius:10.0];
cell.yourImage.clipsToBounds = YES;

希望对您有所帮助

我正在使用名为“viewName”的UIView,但它可以与UIImage一起使用

    //Define background color
    self.viewName setBackgroundColor:[UIColor colorWithRed:(84.0 / 255.0) green:(198.0 / 255.0) blue:(89.0 / 255.0) alpha:1]];

    //Create circular view
    self.viewName.layer.cornerRadius = cell.statusColor.frame.size.width / 2;
    self.viewName.clipsToBounds = YES;

我正在使用名为“viewName”的UIView,但它可以与UIImage一起使用

    //Define background color
    self.viewName setBackgroundColor:[UIColor colorWithRed:(84.0 / 255.0) green:(198.0 / 255.0) blue:(89.0 / 255.0) alpha:1]];

    //Create circular view
    self.viewName.layer.cornerRadius = cell.statusColor.frame.size.width / 2;
    self.viewName.clipsToBounds = YES;

可能重复@pedro.m。如果它是重复的,我承认,但它应该出现在建议中。现在我不明白为什么它被放在了主题之外,因为我要的是代码。我不是在问代码,这是一个概念性的问题。我没有标记为非主题,不要看我@pedro.m.的可复制副本。如果它是重复的,我承认,但它应该出现在建议中。现在我不明白为什么它被放在了主题之外,因为我要的是代码。我不是在问代码,这是一个概念性的问题。我没有标记为非主题,不要看我如果我试图修改单元格中的矩形iBuiImageView,请点击。我需要覆盖UIImageView的initWithFrame,或者如何修改它?我尝试在MyCustomCell的initWithStyle中添加此选项,但它不起作用:
[self.userImage setBackgroundColor:[UIColor orangeColor];[self.userImage.layer setCornerRadius:60.0f]63x64自定义90px高单元中的像素我更新了问题以反映自定义单元类及其init方法。imageview仍然显示为矩形,64x64。是的,我这样做了,它已导入到我的自定义单元格类和构建阶段链接库中。如果我试图修改单元格中的矩形imageview,请单击“确定”。我需要覆盖UIImageView的initWithFrame,或者如何修改它?我尝试在MyCustomCell的initWithStyle中添加此选项,但它不起作用:
[self.userImage setBackgroundColor:[UIColor orangeColor];[self.userImage.layer setCornerRadius:60.0f]63x64自定义90px高单元中的像素我更新了问题以反映自定义单元类及其init方法。imageview仍然显示为矩形,64x64。是的,我这样做了,它被导入到我的自定义单元格类和构建阶段链接库中