Tôi đang cố gắng để thay đổi kích thước một hình ảnh sử dụng stretchableImageWithLeftCapWidth: nó hoạt động trên trình giả lập, nhưng trên thiết bị, quán bar xanh dọc xuất hiện.Thay đổi kích thước một hình ảnh với stretchableImageWithLeftCapWidth
Tôi đã cố gắng sử dụng imageNamed, imageWithContentOfFile và imageWithData lo tải hình ảnh, nó không thay đổi.
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;
Xem kết quả: các thanh màu xanh không nên ở đó, chúng không xuất hiện trên trình giả lập.
alt text http://www.quicksnapper.com/files/5161/96232162149F1C14751048_m.png
Ồ, cảm ơn bạn. –