How to create circular uiviews like Facebook messages


How do I create circular UIView like Facebook messages.

Is it just a rectangle with rounded corners or a rectangle with a circular image in the center?

Here is the image view:

And here is the initWithStyle Code for the custom cell class:

- (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;

But I still get a rectangular imageview.

You have to modify the cornerRadius property on your view's layer. In order to get a circle, you should assign a corner radius equal to half of the views height/width. Here's a basic example:

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];