2

I remember seeing the code before which takes a square image (link an iphone icon) and rounds the corners and adds the effects like apple does in iTunes. Basically I get the icon image from iTunes and want to make it look like it does in the store.

Can anyone point me in the direction?

Jim
  • 72,985
  • 14
  • 101
  • 108
rsirota
  • 321
  • 3
  • 15

3 Answers3

3

You need to import the QuartzCore framework to implement the following:

Your iconView, (in this example) below should be a UIImageView:

[iconView.layer setMasksToBounds:YES];
[iconView.layer setCornerRadius:5.0];

/* setting the border is not necessary, but is an option for you. */
[iconView.layer setBorderWidth:0.0f];
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
1

to round the corners:

#import <QuartzCore/QuartzCore.h>
...
int r = 15;
AnyUIViewSubClass.layer.cornerRadius = r;
SentineL
  • 4,682
  • 5
  • 19
  • 38
1

try these links:

https://stackoverflow.com/a/1850269/215494

https://stackoverflow.com/a/4687593/215494

https://stackoverflow.com/a/8334624/215494

that doesn't add the shine/gloss effect, but if your image size is fixed, you could add another NSImage of a semi-transparent gloss PNG/JPG on top of it, or you could do it entirely programmatically by drawing intersecting NSBezierPaths into NSImage and then compositing the result over your rounded-rect image. you could also compose the whole thing into one final NSImage.

Cocoa With Love has a very nice article about creating icons with gloss, shadows, gradients and all.

Community
  • 1
  • 1
Salam Horani
  • 101
  • 2
  • 9