我是靠谱客的博主 动人超短裙,这篇文章主要介绍正确设定背景图片 ios,现在分享给大家,希望可以做个参考。


在View里放背景图片就像很多其它iOS编程一样有很多方法:

使用UIColor的 colorWithPatternImage来设置背景色;

在view中添加一个UIImageView作为一个子View。

如果你使用全画幅的背景图,你就必须使用UIImageView因为UIColor的colorWithPatternImage是用来创建小的重复的图片作为背景的。这种情形下使用UIImageView可以节约不少的内存:

1
2
3
// You could also achieve the same result in Interface Builder
UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@ "background" ]];
[self.view addSubview:backgroundView];

如果你用小图平铺来创建背景,你就需要用UIColor的colorWithPatternImage来做了,它会更快地渲染也不会花费很多内存:

1
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@ "background" ]];

最后

以上就是动人超短裙最近收集整理的关于正确设定背景图片 ios的全部内容,更多相关正确设定背景图片内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(106)

评论列表共有 0 条评论

立即
投稿
返回
顶部