Modal Segue的意思 取代整个屏幕
Unwind会提供一些方法让modal segue与之前的present的控制器交流或解绑
Alerts会直接弹出来在屏幕正中间他们都是modal的形式,会有询问式的按钮框,也有着输入框比如用户输入的情况.可以收集用户信息.
Action Sheets.不能收集用户信息如果有超过两个的答案的选项就必须要使用Action.出现为从iphone底部滑出.就类似于底部控制一样有很多选项.
//创建一个action sheet
var alert = UIAlertController(
title:”Redeploy Cassini”,
message:Issue commands to Cassini’s guidance system.”,
preferredStyle:UIAlertControllerStyle.ActionSheet
)
//添加一些选项
alert.addAction(UIAlertAction(
title:String,
style:UIAlertActionStyle.Default, //默认的为蓝色的文字 .Destructive 为红色的字 .Cancel为取消
// handler:(action:UIAlertAction) -> Void
{(action:UIAlertAction) -> Void in}
));
alert.modalPresentationStyle = .Popovre//告诉alert的展示样式
let ppc = alert.poperPresentationController
ppc?.barButtonItem = redeployBarButtomItem//重新部署按钮
//调用
presentViewController(alert,animated:true,completion:nil)
//Alert
var alert = UIAlertController(
title:”Login Required”,
message:”Please enter you Cassini ….”,
preferredStyly:UIAlertControllerStyle.Alert,
)
在Alert中放一个输入框
alert.addTextFieldWithConfigurationHandler{(textFiled) in textFiled.placeholder = “Guidance system Password"}
alert.addAction(UIAlertAction(
title:”Login”,
style:.Default,
{(action:UIAlertAction) -> Void in
//获取密码
let tf = self.alert.textFields?.first as UITextField
if tf != nil {self.loginWithPassword(tf.text)}
}
));
NSTimer是一种设置定时器的东西可以周期性低调用一个方法
class fun scheduledTimerWithTimeInterval(
_seconds:NSTimeInterval,//启动的间隔时间
target:AnyObject,//希望向谁发送消息
selector:Selector(String),//需要定时器执行的方法
userInfo:AnyObject?,//类似于cookie,可以在这里存入,每次调用的时候都可以把他取出来
repeats:Bool//
)
timer.invalidate就会停止
timer.tolerance的作用是,比如设置了定时器2分钟后执行,设置了这个参数后如果参数为10,则表示可以在等10秒
animation种类:
一个是view的属性执行动画
另一种是view controller转场
一种叫做Core Animation是UIView Animation的底层
dynamic animation 力学动画
view属性的动画:
frame 这意味着你可以让你的视图到处移动
transform(translation,rotation,scale) 这意味着你可以旋转你的视图或者让他变大变小
alpha(opacity) 透明度
class fun animateWithDuration(
duration:NSTimerInterval, //这是动画会执行的时长
delay:NSTimerInterval, //等待,比如我是否应该等待执行这个动画
options:UIViewAnimationOptions. //
animations:() -> Void, //修改视图属性的地方
completion:((finished:Bool) -> Void)? //完成后的操作
)
关于options:
BeginFormCurrentState
AllowUserInteraction
LayoutSubviews
Repeat
Autoreverse
OverrideInheritedDuration
OverrideInheritedCurve
AllowAnimatedContent
CurveEaseInEaseOut
CurveEaseIn
CurveLinear
flip the entire view over
UIViewAnimationOptionsTransitionFlipFrom{Left,Right,Top,Bottom}
Dissolve from old to new state
UIViewAnimationOptionsTransitionCrossDissolve
Curling up or down
UIViewAnimationOptionsTransitionCurl{Up,Dowm}
//给你一个视图,需要告诉他动画执行多久,想要什么的动画,翻转还是溶解什么的,在动画中可以改变View的参数.
UIView.transitionWithView(
View:UIView,
duration:NSTimerInterval,
options:UIViewAnimationOptions,
animations:() -> Void,
completion:((finished:Bool) -> Void)
)
UIView.transitionFromView(
FromView:UIView,
duration:NSTimerInterval,
options:UIViewAnimationOptions,
animations:() -> Void,
completion:((finished:Bool) -> Void)
)