首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏月亮与二进制

    iOS基础动画教程

    所有的基础动画都给予UIView一个基础的方法:animateWithDuration。 这个方法可以包含一个代码块,里面设置要改变的东西,在执行的时候iOS会自动以动画的形式展现出来,代码如下: [UIView animateWithDuration:1 animations:^{ 很简单,在上面的代码块的位置改变方块的中心就好了,如下: [UIView animateWithDuration:1 animations:^{ // 改变蓝色方块的位置 此外,还可以延迟动画的执行时间,比如想延迟半秒后执行,那么还是同样的方法,但是参数要多一点: [UIView animateWithDuration:1 delay:0.5 options:nil 透明度动画 假设我们想通过动画渐变一个控件的透明度,比如慢慢变成基本看不见,也很简单,还是那个方法: // 开始透明度动画(一秒完成) [UIView animateWithDuration

    1.2K30发布于 2021-11-23
  • 来自专栏月亮与二进制

    《Motion Design for iOS》(三十七)

    CGFloat initialDelay = 1.0f; CGFloat stutter = 0.3f; // 动画箭头图片 [UIView animateWithDuration:2.1 delay arrowView setFrame:CGRectMake(0, 0, windowWidth, 45)]; } completion:NULL]; // 动画Ministry of Fun文字 [UIView animateWithDuration [UIView animateWithDuration:2.1 delay:initialDelay + (2 * stutter) usingSpringWithDamping:0.6 initialSpringVelocity animations:^{ [addButton setFrame:CGRectMake(0, 102, windowWidth, 45)]; } completion:NULL]; [UIView animateWithDuration animations:^{ [firstRow setFrame:CGRectMake(0, 170, windowWidth, 80)]; } completion:NULL]; [UIView animateWithDuration

    52020发布于 2021-11-23
  • 来自专栏一“技”之长

    iOS动画开发之一——UIViewAnimation动画的使用

    二、UIView动画的几个方法 + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations 例如在1S内将view渐变透明: [UIView animateWithDuration:1 animations:^{         _myView.alpha=0;     }]; + (void )animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void 设置一个执行时间和一个执行动作,第二个block块中可以添加一个动画执行结束后的动作,作为补充,例如下面代码的效果,在1S内将view渐变为透明,动画结束后,view在瞬间变回不透明: [UIView animateWithDuration + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping

    1.8K30发布于 2018-08-16
  • 来自专栏ShaoYL

    UI动画效果

    UIView setAnimationDuration:2.0]; /* 需要执行动画的代码 */ //提交动画 [UIView commitAnimations]; 方式2:block式 [UIView animateWithDuration options:kNilOptions animations:^{ /* 需要执行动画的代码 */ } completion:nil]; // 1s后,再执行动画(动画持续2s) [UIView animateWithDuration afterDelay:self.imageView.animationDuration]; 更新View动画 让 self.view 以及它的所有子控件强制更新的动画 //利用 2 秒的时间去更新 [UIView animateWithDuration

    2.4K60发布于 2018-05-11
  • 来自专栏Alice

    demo1 动态显示view或弹框 动态隐藏view或弹框

    [self addSubview:closeBtn]; } //关闭页面 - (void)closeBtnClicked:(UIButton*)sender{ [UIView animateWithDuration CGAffineTransformScale(CGAffineTransformIdentity, 0.3, 0.3); } completion:^(BOOL finished) { [UIView animateWithDuration self.blockCloseClicked(self.hidden); }]; } //点击背景隐藏界面 - (void)tapClose{ [UIView animateWithDuration CGAffineTransformIdentity, 1.0, 1.0); } completion:^(BOOL finished) { [UIView animateWithDuration CGAffineTransformIdentity, 0.3, 0.3); } completion:^(BOOL finished) { [UIView animateWithDuration

    1.4K50发布于 2018-02-01
  • 来自专栏Alice

    demo1 动态显示view或弹框 动态隐藏view或弹框

    [self addSubview:closeBtn]; } //关闭页面 - (void)closeBtnClicked:(UIButton*)sender{ [UIView animateWithDuration CGAffineTransformScale(CGAffineTransformIdentity, 0.3, 0.3); } completion:^(BOOL finished) { [UIView animateWithDuration self.blockCloseClicked(self.hidden); }]; } //点击背景隐藏界面 - (void)tapClose{ [UIView animateWithDuration CGAffineTransformIdentity, 1.0, 1.0); } completion:^(BOOL finished) { [UIView animateWithDuration CGAffineTransformIdentity, 0.3, 0.3); } completion:^(BOOL finished) { [UIView animateWithDuration

    1.5K70发布于 2018-02-01
  • 来自专栏Helloted

    View编程指南(四)

    这些方法是: animateWithDuration:animations: animateWithDuration:animations:completion: animateWithDuration 因此,您可以使用这些方法创建一个包含对多个view进行更改的动画 [UIView animateWithDuration:1.0 animations:^{ firstView.alpha 如果要更改默认的动画参数,则必须使用animateWithDuration:delay:options:animations:completion:方法来执行动画。 默认情况下,嵌套动画会继承父级的持续时间和动画曲线,但即使这些选项可以根据需要被覆盖 [UIView animateWithDuration:1.0 delay: 1.0 [UIView animateWithDuration:1.0 delay:0.0 options: UIViewAnimationOptionCurveLinear animations

    1K10编辑于 2022-06-07
  • 来自专栏一“技”之长

    设计iOS中随系统键盘弹收和内容文字长度自适应高度的文本框

    getValue(&time)         //重设约束         textViewBottom.constant = height         //动画展示         UIView.animateWithDuration :NSTimeInterval=0         value2.getValue(&time)         textViewBottom.constant = 0         UIView.animateWithDuration             textFieldHeight.constant = 37             textViewHeight.constant = 53             UIView.animateWithDuration textFieldHeight.constant = height             textViewHeight.constant = height+16             UIView.animateWithDuration             textFieldHeight.constant = 100             textViewHeight.constant = 116             UIView.animateWithDuration

    2K20发布于 2018-08-15
  • 来自专栏直播知识

    直播带货系统,滚动视图,上滑隐藏,下滑显示

    1  // 没有隐藏         && flag  // 需要隐藏         && offsetY > 0  // 处理顶部下拉回弹         ) {         [UIView animateWithDuration  scrollView.mj_footer.state == MJRefreshStateNoMoreData // 没有更多数据              )) {         [UIView animateWithDuration

    1.4K62发布于 2020-10-15
  • 来自专栏Guangdong Qi

    iOS 连续动画效果(让APP动起来)

    animationDuration:(NSTimeInterval)timer animationBlock:(QuitRentAnimationBlock)block { [UIView animateWithDuration QuitRentAnimationBlock)block { view.transform = CGAffineTransformMakeScale(1.0, 1.0); [UIView animateWithDuration 1.2); }completion:^(BOOL finish){ [UIView animateWithDuration CGAffineTransformMakeScale(0.9, 0.9); }completion:^(BOOL finish){ [UIView animateWithDuration animationDistance:(CGFloat)animationDistance animationBlock:(QuitRentAnimationBlock)block { [UIView animateWithDuration

    2.2K30发布于 2018-05-24
  • 来自专栏哈雷彗星撞地球

    iOS动画三板斧(一)--UIView动画前言UIView 动画

    animation2.gif [UIView animateWithDuration:3.0 animations:^{ squareView.frame = CGRectMake(50 比如这样: [UIView animateWithDuration:3.0 animations:^{ squareView.frame = CGRectMake(50, 50, 100 , 100); } completion:^(BOOL finished) { [UIView animateWithDuration:1.0 animations:^{ 示例代码: [UIView animateWithDuration:3.0 delay:0 options:UIViewAnimationOptionCurveLinear animations animation.gif 示例代码: [UIView animateWithDuration:0.7 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity

    1.3K10发布于 2018-08-22
  • 来自专栏iOS 备忘录

    动画效果:snapshotViewAfterScreenUpdates的使用

        [self.view addSubview:destinationSnapshot];          // 3     sourceView.hidden = YES;     [UIView animateWithDuration removeFromSuperview];                                                    // 4                          [UIView animateWithDuration snapShot.backgroundColor = [UIColor whiteColor];          [self.view addSubview:snapShot];     [UIView animateWithDuration CGAffineTransformMakeScale(1.05, 1.05);         snapShot.alpha = 0.98;     } completion:^(BOOL finished) {         [UIView animateWithDuration

    1.8K22发布于 2021-03-01
  • 来自专栏张志敏的技术专栏

    iOS 系统中的视图动画

    做动画 在 iOS 4.0 以后, 引入了代码块 (code block) 的概念, 可以使用代码块来初始化动画, 这也是在 iOS 4.0 之后苹果推荐的做法, iOS SDK 提供的 API 如下: animateWithDuration :animations: animateWithDuration:animations:completion: animateWithDuration:delay:options:animations: 0.0f; this.SecondView.Alpha = 1.0f; }); 这样就实现了一个简单的渐变动画, 并且只能运行一次, 通常不能满足需求, 再来一个复杂点儿的: [UIView animateWithDuration 例如: [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseOut animations :^{ self.firstView.alpha = 0.0f; // 这里开始一个新的动画 [UIView animateWithDuration:1.0

    3.2K30发布于 2020-08-10
  • 来自专栏全栈程序员必看

    它们的定义UIAlertView

    removeFromSuperview]; } __block CustomAlertView * SELF = self; [UIView animateWithDuration CGAffineTransformIdentity,0.5, 0.5); }completion:^(BOOL finished) { [UIView animateWithDuration } completion:^(BOOL finished) { [UIView animateWithDuration break; default: break; } } // 取消视图 - (void)dismissAlertView{ [UIView animateWithDuration

    1.1K30编辑于 2022-07-06
  • 来自专栏iOS小生活

    自定义一个浮层弹窗视图

    UIView动画 @interface UIView(UIViewAnimationWithBlocks) + (void)animateWithDuration:(NSTimeInterval)duration animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); + (void)animateWithDuration ^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0 + (void)animateWithDuration (^)(void))animations NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0, completion = NULL + (void)animateWithDuration sharedApplication].keyWindowaddSubview:self]; //这里是展示customView的时候的动画,可根据自己的情况自定义 [UIView animateWithDuration

    1.8K30发布于 2019-08-12
  • 来自专栏Alice

    ios textView跟随键盘的移动

    键盘出现隐藏事件 -(void)keyHiden:(NSNotification *)notification { // self.tooBar.frame = rect; [UIView animateWithDuration objectForKey:@"UIKeyboardFrameEndUserInfoKey"]CGRectValue]; // self.tooBar.frame = rect; [UIView animateWithDuration

    2.1K50发布于 2018-02-01
  • 来自专栏服务端技术杂谈

    iOS 开发从 UIView 动画说起

    所以,我们需要使用下面的方法来实现这个效果: [UIView animateWithDuration: 0.5 delay: 0.35 options: UIViewAnimationOptionCurveEaseInOut animations: ^{ self.password.center = passwordCenter; } completion: ^(BOOL finished) { [UIView animateWithDuration ]; [self animatedView: _view4]; //y轴上移动视图上升250 - (void)animatedView: (UIView *)view { [UIView animateWithDuration 这里用到了一个新的动画API方法,transitionWithView: duration: options: animations: completion:,这个方法跟上面的animateWithDuration 因此,我们需要其他的动画方式,系统也正好提供了这样的一种动画供我们使用: + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval

    2.2K70发布于 2018-04-17
  • 来自专栏技术之路

    【swift学习笔记】六.访facebook登录页面

    CGRectValue() { UIView.animateWithDuration(0.25, animations: { CGRectValue() { UIView.animateWithDuration(0.25, animations: { self.view.frame.origin.y

    1K80发布于 2018-01-31
  • 来自专栏iOS逆向与安全

    iOS动画小知识:定点缩放弹窗(利用锚点anchorPoint进行实现)包含完整demo

    [self.layer setAnchorPoint: CGPointMake(1.0f, 0.0f) ]; self.frame = oldFrame; [UIView animateWithDuration MemberCardMenuView 提供一个动画的实例方法 self.cover.hidden = NO; self.cover.alpha = 0; [UIView animateWithDuration )foldView{ /* (0,0) 为左上角,(0,1) 为左下角, (1, 0)右上, (1,1) 右下 */ [UIView animateWithDuration

    2.5K21编辑于 2022-08-22
  • 来自专栏谦谦君子修罗刀

    ios约束

    (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { // 更新约束 [UIView animateWithDuration cyan setNeedsLayout]; // 通知约束更新 [cyan layoutIfNeeded]; }]; // 将现有的约束全部移除 [UIView animateWithDuration

    1.4K50发布于 2018-04-28
领券