我正在使用以下代码尝试创建带有帽插图的平铺图像,并将下面的图像视为模拟器中的结果。我的源图像大小为 145x83 像素,也显示在此处。我究竟做错了什么?
来源图片:
模拟器中的结果:
代码:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *cloudImage = [UIImage imageNamed: @"cloud.png"];
[cloudImage resizableImageWithCapInsets: UIEdgeInsetsMake(10, 10, 10, 10) resizingMode: UIImageResizingModeTile];
UIImageView *imageView1 = [[UIImageView alloc] initWithImage: cloudImage];
[imageView1 setFrame: CGRectMake(50, 50, 100, 100)];
UIImageView *imageView2 = [[UIImageView alloc] initWithImage: cloudImage];
[imageView2 setFrame: CGRectMake(250, 50, 200, 200)];
[self.view addSubview: imageView1];
[self.view addSubview: imageView2];
}