一个从UIImageView中获得Image位置的函数
来源:互联网 发布:淘宝如何刷销量 编辑:程序博客网 时间:2024/05/16 18:42
(CGRect)getFrameSizeForImage:(UIImage *)image inImageView:(UIImageView *)imageView { float hfactor = image.size.width / imageView.frame.size.width; float vfactor = image.size.height / imageView.frame.size.height; float factor = fmax(hfactor, vfactor); // Divide the size by the greater of the vertical or horizontal shrinkage factor float newWidth = image.size.width / factor; float newHeight = image.size.height / factor; // Then figure out if you need to offset it to center vertically or horizontally float leftOffset = (imageView.frame.size.width - newWidth) / 2; float topOffset = (imageView.frame.size.height - newHeight) / 2; return CGRectMake(leftOffset, topOffset, newWidth, newHeight);}
废话不多说贴代码。再stackOverflow中找到的马克下!
- 一个从UIImageView中获得Image位置的函数
- UIButton和UIImageView中Image拉伸效果的实现
- IOS-UIButton和UIImageView中Image拉伸效果的实现
- 重写UIImageView的image属性
- 修改UITableViewCell中UIImageView的位置和大小
- 修改UITableViewCell中UIImageView的位置和大小
- 从一个例子中所获得的启发
- button中image和title的位置
- ceph中如何查找一个对象或者rbd image 的实际存储位置
- 获得网页中image
- IOS UIImageview中Image只显示部分
- Delphi中一个获得窗口图象的函数
- 获得子串在一个字符串中首次出现的位置
- 写一个函数,从一个字符串查找另一个字符串的位置
- 编写一个函数,实现从一个字符串中,查找另一个字符串的位置(笔试题) 例如int func("12345", "34")返回值为2,即在2号位置找到字符串“34”。
- 提供一个Image组件的close函数
- 插件项目中 获得image
- android 获得ImageView中Image的绘制大小
- [gpu pro2]LargeScaleTerrainRenderingForOutdoorGames
- X window manager
- android 4.0.4系统下实现apk的静默安装和启动
- INNO Setup 使用笔记
- ibatis命名空间(namespace)使用
- 一个从UIImageView中获得Image位置的函数
- CListCtrl使用技巧小全
- ubuntu 包管理
- BNUOJ 1098 Tower
- 硬件工程师电路设计十大要点
- 放假第一天——给博客挂了个广告
- CentOS 6.3 yum 安装 memcached
- 敏捷开发“松结对编程”系列之十七:L型代码结构(编程篇之二)(中)
- MongoDB索引操作