UIView的sizeToFit:和fitSize方法
来源:互联网 发布:下载torrent的软件 编辑:程序博客网 时间:2024/06/05 00:08
- (CGSize)sizeThatFits:(CGSize)size; // return 'best' size to fit given size. does not actually resize view. Default is return existing view size
- (void)sizeToFit; // calls sizeThatFits: with current view bounds and changes bounds size.
sizeThatFits:
Asks the view to calculate and return the size that best fits its subviews.
Parameters
- size
The current size of the receiver.
Return Value
A new size that fits the receiver’s subviews.
Discussion
The default implementation of this method returns the size portion of the view’s bounds rectangle. Subclasses can override this method to return a custom value based on the desired layout of any subviews. For example, a UISwitch
object returns a fixed size value that represents the standard size of a switch view, and a UIImageView
object returns the size of the image it is currently displaying.
This method does not resize the receiver.
Availability
- Available in iOS 2.0 and later.
sizeToFit
Resizes and moves the receiver view so it just encloses its subviews.
Discussion
Call this method when you want to resize the current view so that it uses the most appropriate amount of space. Specific UIKit views resize themselves according to their own internal needs. In some cases, if a view does not have a superview, it may size itself to the screen bounds. Thus, if you want a given view to size itself to its parent view, you should add it to the parent view before calling this method.
You should not override this method. If you want to change the default sizing information for your view, override the sizeThatFits:
instead. That method performs any needed calculations and returns them to this method, which then makes the change.
Availability
- Available in iOS 2.0 and later.
- UIView的sizeToFit:和fitSize方法
- UIView的sizeToFit:和fitSize方法
- sizeThatFits and sizeToFit是UIView的两个方法
- sizeThatFits and sizeToFit是UIView的两个方法
- sizeThatFits and sizeToFit是UIView的两个方法, 官方文档上说:
- UIButton的sizeToFit方法无效
- sizeThatFits 和 sizeToFit的区别
- sizeToFit与sizeThatFits的使用和区别
- sizeThatFits 和 sizeToFit区别
- sizeThatFits和sizeToFit
- sizeToFit和sizeThatFit
- sizeToFit和sizeThatFit
- UIView的重要的方法和属性
- sizeToFit的用法
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的setNeedsDisplay和setNeedsLayout方法
- UIView的layoutSubviews和drawRect:方法
- iOS UIView的addSubview:和removeFromSuperview方法
- 使用 jsoup 对 HTML 文档进行解析和操作
- Java中的字符编码(Unicode、UTF-8、UTF-16)的那些事儿
- Oozie Coordinator使用及详解
- Unity让敌人缓慢转向,并且跟踪玩家
- Hbase优秀博客
- UIView的sizeToFit:和fitSize方法
- 黑马程序员--Java基础(一)
- 亲密接触,虚拟现实最重要和最困难的未来
- 指针和指针变量
- Android内存优化大全(二)
- jquery.chosen.js实现模糊搜索
- 史上最详细的Android Studio系列教程(二)
- mysql数据库的字符集相关
- CSS三栏布局——中间固定两边自适应宽度