UIView的几个枚举定义
UIView是iOS开发最主要的视图,非常多控件都是继承它,掌握当中的几个基本枚举定义,有利益理解视图的载入和參数差别。
一、UIViewAnimationCurve
UIView的基本动画变化规律
typedef NS_ENUM(NSInteger, UIViewAnimationCurve) {
UIViewAnimationCurveEaseInOut, // 淡入淡出
UIViewAnimationCurveEaseIn, // 開始时慢
UIViewAnimationCurveEaseOut, // 结束时慢
UIViewAnimationCurveLinear, //线性变化
};
用法:
在UIView(UIViewAnimation)的动画分类中使用
+ (void)setAnimationCurve:(UIViewAnimationCurve)curve; // default = UIViewAnimationCurveEaseInOut
二、UIViewContentMode
内容模型。主要用于图片显示(是否变形)
总则:凡是没有带scale的。图片大小与content大小不一致。都不会变形,都有可能留下空白。
UIView的ContentMode图片填充
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill, //全然填充,有可能拉伸
UIViewContentModeScaleAspectFit, //保证图片比例。可是人有可能会有空白
UIViewContentModeScaleAspectFill, //保证图片比例,并且占满。可是可能仅仅会显示部分
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop, //对齐顶部
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
用法:UIView(UIViewRendering)渲染
@property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill
三、UIViewAnimationTransition
用于简单视图动画过渡。
假设须要使用到更深层次的过渡在layer层加CATransition【传送门】
typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone, //正常
UIViewAnimationTransitionFlipFromLeft, //从左往右翻
UIViewAnimationTransitionFlipFromRight, //从右往左翻
UIViewAnimationTransitionCurlUp, //从上往下卷
UIViewAnimationTransitionCurlDown, //从下网上卷
};
用法:UIVeiw(UIViewAnimation) 动画
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache; // 仅仅有在開始和结束动画块之间设置才有效果
四、UIViewAutoresizing
该定义用于自己主动调节子控件在父控件的位置和宽高,以保证能够适应多种屏幕。
这是一个位移型枚举,能够一次使用多种状态,本身也能够设置多种自己主动调整。
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0, //不调整
UIViewAutoresizingFlexibleLeftMargin = 1 << 0, //自己主动调整View与父视图的左边距。保证右边距不变
UIViewAutoresizingFlexibleWidth = 1 << 1, //自己主动调整View宽度。保证左右边距不变
UIViewAutoresizingFlexibleRightMargin = 1 << 2, //自己主动调整view与父视图的右边距,保证左边距不变
UIViewAutoresizingFlexibleTopMargin = 1 << 3, //自己主动调整View与父视图的下边距,保证上边距不变
UIViewAutoresizingFlexibleHeight = 1 << 4, //自己主动调整View的高度,保证上下边距不变
UIViewAutoresizingFlexibleBottomMargin = 1 << 5 //自己主动调整View与父视图的上边距。保证下边距不变
};
方法使用:UIView(UIViewGeometry)几何
@property(nonatomic) UIViewAutoresizing autoresizingMask; // simple resize. default is UIViewAutoresizingNone
提示:这个枚举用于UIView的autoresizingMask属性值。自己定义控件时经常须要设置。
五、UIViewAnimationOptions
该枚举主要用于动画过渡的。能够设置多个值,假设须要复杂动画还是得使用Core Animation。
这个为简单的动画方法的參数,简单设置能够实现动画。
1.常规动画属性设置(能够同一时候选择多个进行设置)
UIViewAnimationOptionLayoutSubviews:动画过程中保证子视图尾随运动。 **提交动画的时候布局子控件。表示子控件将和父控件一同动画。**
UIViewAnimationOptionAllowUserInteraction:动画过程中同意用户交互。
UIViewAnimationOptionBeginFromCurrentState:全部视图从当前状态開始执行。 UIViewAnimationOptionRepeat:反复执行动画。
UIViewAnimationOptionAutoreverse :动画执行到结束点后仍然以动画方式回到初始点。**执行动画回路,前提是设置动画无限反复**
UIViewAnimationOptionOverrideInheritedDuration:忽略嵌套动画时间设置。**忽略外层动画嵌套的时间变化曲线**
UIViewAnimationOptionOverrideInheritedCurve:忽略嵌套动画速度设置。 **通过改变属性和重绘实现动画效果。假设key没有提交动画将使用快照**
UIViewAnimationOptionAllowAnimatedContent:动画过程中重绘视图(注意只适用于转场动画)。
UIViewAnimationOptionShowHideTransitionViews:视图切换时直接隐藏旧视图、显示新视图,而不是将旧视图从父视图移除(只适用于转场动画)**用显隐的方式替代加入移除图层的动画效果**
UIViewAnimationOptionOverrideInheritedOptions :不继承父动画设置或动画类型。 **忽略嵌套继承的选项**
----------------------------------------------------------------------------
2.动画速度控制(可从当中选择一个设置)时间函数曲线相关**时间曲线函数**
UIViewAnimationOptionCurveEaseInOut:动画先缓慢,然后逐渐加速。
UIViewAnimationOptionCurveEaseIn :动画逐渐变慢。 UIViewAnimationOptionCurveEaseOut:动画逐渐加速。 UIViewAnimationOptionCurveLinear :动画匀速执行,默认值。
-----------------------------------------------------------------------------
3.转场类型(仅适用于转场动画设置,能够从中选择一个进行设置,基本动画、关键帧动画不须要设置)**转场动画相关的**
UIViewAnimationOptionTransitionNone:没有转场动画效果。
UIViewAnimationOptionTransitionFlipFromLeft :从左側翻转效果。
UIViewAnimationOptionTransitionFlipFromRight:从右側翻转效果。 UIViewAnimationOptionTransitionCurlUp:向后翻页的动画过渡效果。
UIViewAnimationOptionTransitionCurlDown :向前翻页的动画过渡效果。 UIViewAnimationOptionTransitionCrossDissolve:旧视图溶解消失显示下一个新视图的效果。
UIViewAnimationOptionTransitionFlipFromTop :从上方翻转效果。
UIViewAnimationOptionTransitionFlipFromBottom:从底部翻转效果。
使用方式:UIView(UIViewAnimationWithBlocks)
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0); + (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); + (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // toView added to fromView.superview, fromView removed from its superview + (void)performSystemAnimation:(UISystemAnimation)animation onViews:(NSArray<__kindof UIView *> *)views options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))parallelAnimations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);
六、UIViewKeyframeAnimationOptions
该定义也是用于动画的,可是这个是能够通过关键帧。降低前几种动画方式的代码嵌套和代码量过多问题【差别和使用实例】
typedef NS_OPTIONS(NSUInteger, UIViewKeyframeAnimationOptions) {
UIViewAnimationOptionLayoutSubviews//进行动画时布局子控件
UIViewAnimationOptionAllowUserInteraction//进行动画时同意用户交互
UIViewAnimationOptionBeginFromCurrentState//从当前状态開始动画
UIViewAnimationOptionRepeat//无限反复运行动画
UIViewAnimationOptionAutoreverse//运行动画回路
UIViewAnimationOptionOverrideInheritedDuration//忽略嵌套动画的运行时间设置
UIViewAnimationOptionOverrideInheritedOptions//不继承父动画设置
UIViewKeyframeAnimationOptionCalculationModeLinear//运算模式:连续
UIViewKeyframeAnimationOptionCalculationModeDiscrete//运算模式:离散
UIViewKeyframeAnimationOptionCalculationModePaced//运算模式:均匀运行
UIViewKeyframeAnimationOptionCalculationModeCubic//运算模式:平滑
UIViewKeyframeAnimationOptionCalculationModeCubicPaced//运算模式:平滑均匀 } NS_ENUM_AVAILABLE_IOS(7_0);
用法:UIView(UIViewkeyframeAnimation)关键帧动画
+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);
其它枚举
//移除view结束
typedef NS_ENUM(NSUInteger, UISystemAnimation) {
UISystemAnimationDelete, // removes the views from the hierarchy when complete
} NS_ENUM_AVAILABLE_IOS(7_0); 用法:
+ (void)performSystemAnimation:(UISystemAnimation)animation onViews:(NSArray<__kindof UIView *> *)views options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))parallelAnimations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0); //用于字体设置的
typedef NS_ENUM(NSInteger, UIViewTintAdjustmentMode) {
UIViewTintAdjustmentModeAutomatic, UIViewTintAdjustmentModeNormal,
UIViewTintAdjustmentModeDimmed, //字体模式 暗灰色
} NS_ENUM_AVAILABLE_IOS(7_0);
使用属性:
@property(nonatomic) UIViewTintAdjustmentMode tintAdjustmentMode NS_AVAILABLE_IOS(7_0);
typedef NS_ENUM(NSInteger, UISemanticContentAttribute) {
UISemanticContentAttributeUnspecified = 0,
UISemanticContentAttributePlayback, // for playback controls such as Play/RW/FF buttons and playhead scrubbers
UISemanticContentAttributeSpatial, // for controls that result in some sort of directional change in the UI, e.g. a segmented control for text alignment or a D-pad in a game
UISemanticContentAttributeForceLeftToRight,
UISemanticContentAttributeForceRightToLeft
} NS_ENUM_AVAILABLE_IOS(9_0);
用法:
@property (nonatomic) UISemanticContentAttribute semanticContentAttribute NS_AVAILABLE_IOS(9_0); // This method returns the layout direction implied by the provided semantic content attribute relative to the application-wide layout direction (as returned by UIApplication.sharedApplication.userInterfaceLayoutDirection).
+ (UIUserInterfaceLayoutDirection)userInterfaceLayoutDirectionForSemanticContentAttribute:(UISemanticContentAttribute)attribute NS_AVAILABLE_IOS(9_0); // This method returns the layout direction implied by the provided semantic content attribute relative to the provided layout direction. For example, when provided a layout direction of RightToLeft and a semantic content attribute of Playback, this method returns LeftToRight. Layout and drawing code can use this method to determine how to arrange elements, but might find it easier to query the container view’s effectiveUserInterfaceLayoutDirection property instead.
+ (UIUserInterfaceLayoutDirection)userInterfaceLayoutDirectionForSemanticContentAttribute:(UISemanticContentAttribute)semanticContentAttribute relativeToLayoutDirection:(UIUserInterfaceLayoutDirection)layoutDirection NS_AVAILABLE_IOS(10_0);
UIView的几个枚举定义的更多相关文章
- [改善Java代码]推荐使用枚举定义常量
枚举和注解都是在Java1.5中引入的,虽然他们是后起之秀,但是功能不容小觑,枚举改变了常量的声明方式,注解耦合了数据和代码. 建议83:推荐使用枚举定义常量 一.分析 常量的声明是每一个项目中不可或 ...
- 拔高你的Java代码质量吧:推荐使用枚举定义常量(转)
提高你的Java代码质量吧:推荐使用枚举定义常量 一.分析 常量的声明是每一个项目中不可或缺的,在Java1.5之前,我们只有两种方式的声明:类常量和接口常量.不过,在1.5版之后有了改进,即新增了一 ...
- python3 枚举定义和使用
定义 在某些情况下,一个类的对象是有限且固定的,比如季节类,它只有 4 个对象:再比如行星类,目前只有 8 个对象.这种实例有限且固定的类,在 Python 中被称为枚举类.程序有两种方式来定义枚举类 ...
- 一个C++宏定义与枚举定义重复的编译错误
C++的开发效率低是众所周知的,原因比如有: 语言复杂度高 编译效率低 工具链不够完整高效(尤其是linux下) 另外一个恐怕是不少编译错误让人摸不着头脑,今天碰到一个,举个例子: #include ...
- oc中的枚举定义
typedef NS_ENUM(类型,枚举名){ 枚举名+值名, 枚举名+值名,}; 该方法定义的枚举,OC会自动把其转换成合适当前版本的枚举.如果枚举值可合并的话 NS_E ...
- 提高Java代码质量:使用枚举定义常量(转)
一.分析 常量的声明是每一个项目中不可或缺的,在Java1.5之前,我们只有两种方式的声明:类常量和接口常量.不过,在1.5版之后有了改进,即新增了一种常量声明方式,枚举常量.代码如下: enum ...
- C++中枚举定义运算符
由于枚举也是用户定义类型,所以是可以定义运算符, 如: enum Day {sun, mon, tue, wen, thu, fri, sat}; Day& operator++(Day&am ...
- iOS中枚举定义的三种方式
最简单的方式 typedef enum{ num1 = 0, num2 = 1, num3 = 2 }num; 同时我们还可以使用NS_ENUM的方式定义枚举 typedef NS_ENUM (NSI ...
- C# 给枚举定义DescriptionAttribute,把枚举转换为键值对
在C#中,枚举用来定状态值很方便,例如我定义一个叫做Season的枚举 public enum Season { Spring = 1, Summer = 2, Autumn = 3, Winter ...
随机推荐
- 小半斤拔凉 支付Java 相关参考
http://git.oschina.net/littleCrazy/dianshangpingtai-zhifu http://git.oschina.net/52itstyle/springMvc ...
- 分享六:php脚本守护进程
http://www.baidufe.com/item/9565cec0004cb49d25fd.html
- 【Android】8.1 主题基本用法
分类:C#.Android.VS2015: 创建日期:2016-02-17 一.创建本章示例主界面 1.界面截图 2.MainActivity.cs文件中对应的代码 在CreateChItems()方 ...
- 关于python调用zabbix api接口
因公司业务需要,引进了自动化运维,所用到的监控平台为zbbix3.2,最近正在学习python,计划使用python调用zabbix api接口去做些事情,如生成报表,我想最基本的是要取得zabbix ...
- iOS自定义组与组之间的距离以及视图
iOS自定义组与组之间的距离以及视图 //头视图高度 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(N ...
- pssh安装和使用
前提,安装了python.pssh安装下载pssh-2.2.2.tar.gztar zxvf pssh-2.2.2.tar.gzcd pssh-2.2.2python setup.py buildpy ...
- PLSQL连接本机oracle 11g 64 数据库的步骤
1.登录PL/SQL Developer 这里省略Oracle数据库和PL/SQL Developer的安装步骤,注意在安装PL/SQL Developer软件时,不要安装在Program Files ...
- 处理oracle 报ORA-12505 信息:listener does not currently know of SID given in connect descriptor...
oracle 的 sql developer连接不上问题: sql developer连接本机的服务器时,有时候能连接,有时候连接不上,什么原因造成的呢? ①检查oracle服务器和监听器是否已经启动 ...
- tomcat8源码分析-Connector初始化
谈起Tomcat的诞生,最早可以追溯到1995年.近20年来,Tomcat始终是使用最广泛的Web服务器,由于其使用Java语言开发,所以广为Java程序员所熟悉.很多人早期的J2EE项目,由程序员自 ...
- 基于jQuery左右滑动切换图片代码
分享一款基于jQuery左右滑动切换图片代码.这是一款基于jQuery实现的左右滑动切换焦点图代码.效果图如下: 在线预览 源码下载 实现的代码: <div class="v_ou ...