我正在嘗試使用stretchableImageWithLeftCapWidth調整圖片大小:它可以在模擬器上工作,但在設備上會出現垂直綠色條。使用stretchableImageWithLeftCapWidth調整圖片大小
我試圖使用imageNamed,imageWithContentOfFile和imageWithData lo加載圖像,它不會改變。
UIImage *bottomImage = [[UIImage imageWithData:
[NSData dataWithContentsOfFile:
[NSString stringWithFormat:@"%@/bottom_part.png",
[[NSBundle mainBundle] resourcePath]]]]
stretchableImageWithLeftCapWidth:27 topCapHeight:9];
UIImageView *bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 200+73, 100, 73)];
[self.view addSubview:bottomView];
UIGraphicsBeginImageContext(CGSizeMake(100, 73));
[bottomImage drawInRect:CGRectMake(0, 0, 100, 73)];
UIImage *bottomResizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
bottomView.image = bottomResizedImage;
查看結果:綠條不應該在那裏,它們不會出現在模擬器上。
alt text http://www.quicksnapper.com/files/5161/96232162149F1C14751048_m.png
哇,謝謝。 – 2009-12-03 17:24:51