我在为文本视图设置自定义背景时遇到了一些问题。据我所知,我可以使用png图像文件,并根据我的文本视图的大小调整其大小,如下所示:
UIImage *bubble = [[UIImage imageNamed:@"blue-bubble.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(12, 6, 6, 12)];
UITextView *textIn = [[UITextView alloc] initWithFrame:CGRectMake(0, y, 320, 30)];
textIn.backgroundColor = [UIColor colorWithPatternImage:bubble];
发生的情况是,即使在尝试更改UIEdgeInsetsMake方法的参数后,图像的大小也没有正确调整。
我不确定我哪里错了。
显然,您不能使用colorWithPatternImage
方法来调整图像大小,这导致了问题。我通过为每个文本视图创建单独的imgview并将imgview定位在文本视图后面来解决这个问题。
希望这能帮助到其他人。