- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 MainViewController
,它有堆栈 View ,它的宽度超过了屏幕的宽度。 storyboard
左侧有滑出式菜单。屏幕上有一个菜单按钮,它触发动画将 UIStackView
从 -260 更改为 0。但是当我在滑出菜单中单击某个按钮时,prepareForSegue()
立即覆盖动画和内容更改。怎么解决这个问题?
您可以在下面找到 gif。
代码如下:
class MainViewController: UIViewController
{
var container: ContainerViewController?
@IBOutlet weak var superView: UIStackView!
@IBAction func menuButtonsChangeContent(sender: AnyObject) {
switch(sender.tag){
case 1:
container?.changeContent("first")
case 2:
container?.changeContent("second")
case 3:
container?.changeContent("third")
default:
break
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "Container"{
self.slideOutMenu("")
container = segue.destinationViewController as? ContainerViewController
}
}
@IBAction func slideOutMenu(sender: AnyObject) {
if self.superView.frame.origin.x != -260 {
UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0.5, options: .CurveEaseInOut, animations: ({
self.superView.frame = CGRect(x: -260, y: 20, width: self.superView.frame.width, height: self.superView.frame.height)
}), completion: nil)
}else{
UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0.5, options: .CurveEaseInOut, animations: ({
self.superView.frame = CGRect(x: 0, y: 20, width: self.superView.frame.width, height: self.superView.frame.height)
}), completion: nil)
}
}
}
//ContainerViewController.swift
class ContainerViewController: UIViewController
{
var sourceVC: UIViewController?
var destinationVC: UIViewController?
var segueIdentifier: String?
var counter = 0
func changeContent(segueIdentifier: String)
{
self.performSegueWithIdentifier(segueIdentifier, sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0.5, options: .CurveEaseInOut, animations: ({
if self.sourceVC != nil {
self.sourceVC?.view.removeFromSuperview()
print("deleted")
}
self.destinationVC = segue.destinationViewController
self.addChildViewController(self.destinationVC!)
self.destinationVC?.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview((self.destinationVC?.view)!)
self.destinationVC?.didMoveToParentViewController(self)
self.sourceVC = self.destinationVC
}), completion: nil)
}
}
和 Storyboard:
动图:
最佳答案
我在 MainViewController
中使用 UIStackView
作为 super View ,但是出现了关于阴影的问题,我将 UIStackView
更改为 UIView
。也许这很奇怪,但问题已经消失了。
关于swift - 如何修复 `prepareForSegue()` 覆盖 `UIViewAnimation`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34253878/
有什么方法可以像下面这样以“简短而简单”的方式做事?曲线似乎仍然使用 EaseOut . [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
我有一个 UIImageView,它应该从顶部滑入 View ,然后当它停止时它应该制作一个弹跳动画。 我正在像这样设置 y.position 变化的动画: [UIView animateW
我收到这个警告 从枚举类型“UIViewAnimationCurve”到不同枚举类型“UIViewAnimationTransition”的隐式转换 这段代码的最后一行 if (((UIView*)[
我想知道当您将选择器分配给未声明的 animationDidStopSelector 时会发生什么。 例如: [UIView setAnimationDidStopSelector:@selector
我有一个简单的 UILabel,当你长按它时它会开始旋转。我使用以下代码成功实现了这一点: -(IBAction)longPressEffect:(UILongPressGestureRecogniz
我有两个交叉渐变 View Controller ,它们都在其 subview 中播放视频。 View A 中的视频在淡入开始时开始播放,在淡出结束时停止。 View B 中的视频在淡入时开始,在淡出
我有这个“闪光”动画,它通过 CGAffineTransformMakeScale 和 UIViewAnimation 使 View (使用点击识别器)变大和变小。问题是用户无法在按钮仍在播放动画时点
我有 MainViewController,它有堆栈 View ,它的宽度超过了屏幕的宽度。 storyboard 左侧有滑出式菜单。屏幕上有一个菜单按钮,它触发动画将 UIStackView 从 -
目标: 在单个 UIView 上同时播放多个动画。 问题: 据我所知,这是不可能的。每个动画必须按顺序出现,不能重叠。 本质上,我希望单个 UIView 在垂直方向上设置动画,同时在水平方向上设置动画
在我的项目中,我每秒调用 NSTimer 1000 次。有了它,我可以使用 UIViewanimation 同时在某些 ImageView 中每次点击分配 5 个 UIImage 对象。当我做这项工作
在 swift 3 更新中,我收到此错误消息 如果方法调用有任何变化,请告诉我。 谢谢 最佳答案 curveEaseInOut需要使用数组: UIView.animate(withDuration:
我有一个 iOS 10 应用程序,其中包含一个按钮(“按我!”)和一个包含蓝色轮廓矩形且无填充的 UIView。我想使用任何可能的方法(我尝试使用 UIView.animation(withDurat
构建包含抽认卡的应用。他们肯定需要翻牌的能力。为此,我有一个 UIViewController 并且为了避免翻转整个 View ,我将我的 subview 实现到一个容器中。 我在名为frontVie
如何在 UIView 动画 block 中将 UIViewAnimationOptions 设置为 .Repeat: UIView.animateWithDuration(0.2, delay:0.2
我尝试返回第一个 View 并为其设置动画。然而动画不起作用。代码如下所示: - (IBAction)geriBtnClick:(id)sender { [UIView beginAnimations
这是我为图像提供交叉溶解效果的代码 - (void)viewDidLoad { [super viewDidLoad]; typedef enum { UIVi
我是一名优秀的程序员,十分优秀!