<UI>实现背景拉伸的方法(聊天气泡)
方法1:能够使得背景图片可以拉伸。
UIView *theMainView =[ [UIView alloc] init]; UIImage *image = [UIImage imageNamed:@"bg.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image] ; [theMainView addSubview:imageView];
//这个方法两个参数分别表示左边和上边不拉升的像素
UIImageView *bubble=[[UIImageView alloc] initWithImage:[image stretchableImageWithLeftCapWidth:10 topCapHeight:10]];
方法2:
[theMainView setBackgroundColor: [UIColor colorWithPatternImage: [UIImage imageNamed: @"bg.png"]]];