我有一个UIView
我这样设置背景图片:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sfond-appz.png"]];
我的问题是背面图像不在视图内居中,但会重播几次以填充所有视图。有没有办法将 uiview 和 scretch 中的图像居中以获取屏幕尺寸?
注意:我不能使用UIImageView
对于背景原因我有一个scrollview
.
您需要预先处理图像,以制作居中且拉伸的图像。
尝试这个:
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"image.png"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)