iOS项目中瀑布流占位图问题
来源:互联网 发布:阿里农村淘宝事业部 编辑:程序博客网 时间:2024/05/19 05:31
项目环境:首页商品瀑布流图片展示。
问题:使用瀑布流展示商品,网络获取图片时,占位图被拉伸。
解决:将logo重新绘制到当前范围的中心,并生成图片,作为占位图使用。
/**
将占位图片绘制在当前图片中央
@param image image 居中的logo图片
@param size size 当前需要施画的范围
@param backgroundColor backgroundColor 背景画布颜色
@return 绘制好的logo居中图片
*/
- (UIImage *)drawImage:(UIImage*)image
size:(CGSize)size
backgroundColor:(UIColor *)backgroundColor
{
UIGraphicsBeginImageContextWithOptions(size,0, [UIScreenmainScreen].scale);
[backgroundColor set];
UIRectFill(CGRectMake(0,0, size.width, size.height));
CGFloat imageX = (size.width /2) - (image.size.width /2);
CGFloat imageY = (size.height /2) - (image.size.height /2);
[image drawInRect:CGRectMake(imageX, imageY, image.size.width, image.size.height)];
UIImage *resImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resImage;
}
- iOS项目中瀑布流占位图问题
- iOS开发 | UITableView的无数据占位图在项目中的实际运用
- iOS中瀑布流的添加
- 用Glide加载图片到Recyclerview中有时候只显示占位图的问题
- iOS中位图数据处理
- iOS开发造轮子 | UIView及其子类的占位图
- ios瀑布流心得
- iOS 瀑布流
- ios瀑布流心得
- ios瀑布流心得
- iOS 瀑布流实现
- ios 瀑布流
- iOS瀑布流
- iOS UICollectionView瀑布流
- ios瀑布流
- iOS瀑布流
- iOS 不规则瀑布流
- iOS瀑布流Demo
- Screen 管理远程会话
- nginx 服务器重启命令,关闭
- Struts旅程(四)MVC向struts MVC框架演变过程
- canvas学习之路(二)特殊绘图功能及实例
- Request&Response_重定向和转发
- iOS项目中瀑布流占位图问题
- 百度地图 keystone的问题
- ubuntu新版wireshark的升级与回退
- 理解js的全局变量和局部变量
- 具有记忆功能的数据结构
- 0002算法笔记——【递归】排列问题,整数划分问题,Hanoi问题
- 配置以太网网关为A类IP(1.1.1.0)的随笔
- Mockito
- js两种显示日期的方法