Sovannarith
Sovannarith

Reputation: 616

Draw an Item like home screen icon of iPhone

I want to draw an Item that similar as item of iPhone. I have also draw with UIView like thisenter image description here

But the item I want like this : enter image description here

How can I draw like round buttton?

Upvotes: 1

Views: 180

Answers (3)

Prabhjot Singh Gogana
Prabhjot Singh Gogana

Reputation: 1408

USE THIS CODE

  UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  [bt setFrame:CGRectMake(10, 10, 50, 50)];
  [bt setImage:[UIImage imageNamed:@"abc.png" ] forState:UIControlStateNormal];

  // Get the Layer of any view
  CALayer * l = [bt layer];
  [l setMasksToBounds:YES];
  [l setCornerRadius:10.0];

  // You can even add a border
  [l setBorderWidth:4.0];
  [l setBorderColor:[[UIColor blueColor] CGColor]];
  [self.view addSubview:bt];

Upvotes: 2

Matthias
Matthias

Reputation: 8180

You can make round edges by

 yourview.layer.cornerRadius = 8.0; // or other value

Upvotes: 1

Suresh Varma
Suresh Varma

Reputation: 9740

Set the corner Radius of your view and insert the label below it.

iPhone supports the cornerRadius property on the CALayer class. Every view has a CALayer instance that you can manipulate.

First of all #import <QuartzCore/QuartzCore.h> and link to the QuartzCore framework to get access to CALayer's headers and properties.Then,

yourView.layer.cornerRadius = 8;

Upvotes: 1

Related Questions