0
customBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[customBtn setFrame:CGRectMake(200,200,68,68)];
UIImage *btnImage = [UIImage imageNamed:@"dash_pulsante_attivo"];
[customBtn setImage:btnImage forState:UIControlStateNormal];
[customBtn addTarget:self action:@selector(triggerMeasurement) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:customBtn];

I'm building a custom button that should be using a 68x68 png for it's normal state. But the image looks deformed: it should be a circle, but it display as an oval. Any hint or suggestion why it is happening? Curiously, I've tried to swap with another circular png, 220x220, and everything works as expected.

iDeveloper
  • 223
  • 2
  • 5
Sr.Richie
  • 5,680
  • 5
  • 38
  • 62
  • check the png size is 68x68 or not?? if size is ok means check whether you are changing this button frame in some other place of your code... – Venk May 24 '13 at 11:23
  • can you able to attach the screenshot?? – Venk May 24 '13 at 11:23
  • check the image "dash_pulsante_attivo" resolution. – Vignesh May 24 '13 at 11:38
  • Sorry guys, it was a stupid error, my fault. I checked like 20 times if the images had the right size, but I was checking on the finder (not the one I imported in my project). The error was that I imported in my project the original image - that was bigger. Quite embarassing :) – Sr.Richie May 24 '13 at 11:41

2 Answers2

0

I hope this error happened, because of image size, check whether the image size is 68x68.

nothing wrong in your code.

Bharathi D
  • 953
  • 1
  • 15
  • 28
  • Sorry guys, it was a stupid error, my fault. I checked like 20 times if the images had the right size, but I was checking on the finder (not the one I imported in my project). The error was that I imported in my project the original image - that was bigger. Quite embarassing :) – Sr.Richie May 24 '13 at 11:42
0

check the image "dash_pulsante_attivo" resolution. If it's less than 68*68 it supposed to get distorted. Higher resolution won't have distortion problem.

If you want resize your image programatically. You can do like this.

Community
  • 1
  • 1
Vignesh
  • 10,205
  • 2
  • 35
  • 73