View Content Mode

本文介绍了视图内容模式(ContentModes)的基本概念及其作用原理。内容模式控制视图如何响应几何变化并决定是否重复使用内容。文章详细解释了不同模式如ScaleToFill、AspectFit和Redraw之间的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Content Modes

Each view has a content mode that controls how the view recycles its content in response to changes in theview’s geometry and whether it recycles its content at all. When a view is first displayed, it renders its contentas usual and the results are captured in an underlying bitmap. After that, changes to the view’s geometry donot always cause the bitmap to be recreated. Instead, the value in the contentMode property determineswhether the bitmap should be scaled to fit the new bounds or simply pinned to one corner or edge of theview. 


详情可以查看View Programming Guide里的Content Mode

各个选项都很简单 Scale To Fill 和 Aspect Fit的区别就是方向上的适应整个View

Redraw:to redraw themselvesduring scaling and resizing operations 

 Setting your view’s content mode to this value forces the system tocall your view’s drawRect: method in response to geometry changes. In general, you should avoid using thisvalue whenever possible, and you should certainly not use it with the standard system views. 


view Mode 有下面这几个选项:





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值