如何在iPhone中调整按钮图像的大小

时间:2011-01-05 05:39:09

标签: iphone

我是iphone中的新手。现在我在iphone中开发按钮图像。这里的图像是大尺寸视图。我想调整图像大小。我实现这样的代码。

images = [[NSMutableArray alloc]init];
 [images addObject:[UIImage imageNamed:@"bearlarge.jpg"]];
 [images addObject:[UIImage imageNamed:@"bufflo_large.jpg"]];
 [images addObject:[UIImage imageNamed:@"camel_large.jpg"]];
 UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

 int row = 0;
 int column = 0;


 for(int i = 0; i < images.count; ++i) {



 // UIImage *thumb = [images objectAtIndex:i];

  UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];



   button.frame = CGRectMake(column*105+14, row*105+10, 50,50);


  [button setImage:[images objectAtIndex:i] forState:UIControlStateNormal];
  [button addTarget:self 
       action:@selector(buttonClicked:) 
   forControlEvents:UIControlEventTouchUpInside];
  button.tag = i; 




  [view addSubview:button];

  if (column == 2) {
   column = 0;
   row++;
  } else {
   column++;
  }
   }
 //[view setContentSize:CGSizeMake(320, (row+1) * 80 + 10)];
    self.view = view;
 [view release]; 

任何人都可以发送代码来调整iphone中图像的大小。

提前谢谢你。

0 个答案:

没有答案