zoukankan      html  css  js  c++  java
  • 控件基本动画

     1 #import "BasicViewController.h"
     2 
     3 @interface BasicViewController ()
     4 //用来测试动画效果的一个视图
     5 @property (weak, nonatomic) IBOutlet UIView *testView;
     6 
     7 @end
     8 
     9 @implementation BasicViewController
    10 
    11 - (void)viewDidLoad {
    12     [super viewDidLoad];
    13     
    14     
    15 }
    16 #pragma mark - 动态的改变frame
    17 - (IBAction)changeFrameAction:(UIButton *)sender {
    18    //UIView动画起始于beginAnimation终止于commitAnimation
    19     //第一步:开始设置UIView动画
    20     [UIView beginAnimations:@"move" context:nil];
    21     //第二步:设置播放时长
    22     [UIView setAnimationDuration:2];
    23     //第三步:设置UIView回调的对象(即代理)
    24     [UIView setAnimationDelegate:self];
    25     //第四步:设置要改变的内容
    26     self.testView.frame = CGRectMake(100, 100, 200, 100);
    27     //第五步:提交动画效果
    28     [UIView commitAnimations];
    29     
    30     
    31 }
    32 - (IBAction)changeColor:(UIButton *)sender {
    33     [UIView beginAnimations:@"颜色" context:nil];
    34     [UIView setAnimationDuration:2];
    35     [UIView setAnimationDelegate:self];
    36     self.testView.backgroundColor = [UIColor magentaColor];
    37     [UIView commitAnimations];
    38 }
    39 - (IBAction)changeAlpha:(UIButton *)sender {
    40     [UIView beginAnimations:@"alpha" context:nil];
    41     [UIView setAnimationDuration:2];
    42     [UIView setAnimationDelegate:self];
    43     self.testView.alpha = 0.5;
    44     [UIView commitAnimations];
    45 }
    46 - (IBAction)changeBounds:(UIButton *)sender {
    47     [UIView beginAnimations:@"bounds" context:nil];
    48     [UIView setAnimationDuration:2];
    49     [UIView setAnimationDelegate:self];
    50     self.testView.bounds = CGRectMake(30, 40, 100, 100);
    51     [UIView commitAnimations];
    52 }
    53 //仿射翻转
    54 - (IBAction)totationAction:(UIButton *)sender {
    55     //第一步:开始动画
    56     [UIView beginAnimations:@"仿射翻转" context:nil];
    57     //第二步:设置时长
    58     [UIView setAnimationDuration:3];
    59     //第三步:设置淡入的效果
    60     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    61     //第四步:设置代理
    62     [UIView setAnimationDelegate:self];
    63     //第五步:设置翻转的方向
    64     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.testView cache:YES];
    65     //第六步:提交
    66     [UIView commitAnimations];
    67     
    68 }
    69 - (IBAction)transformAction:(UIButton *)sender {
    70     [UIView beginAnimations:@"仿射旋转" context:nil];
    71     [UIView setAnimationDuration:3];
    72     [UIView setAnimationDelegate:self];
    73     //设置旋转的度数
    74     CGAffineTransform transform = CGAffineTransformMakeRotation(3 * M_PI);
    75     //设置旋转对象
    76     [self.testView setTransform:transform];
    77     [UIView commitAnimations];
    78 }
    79 
    80 #pragma mark - UIViewAnimation的代理方法
    81 -(void)animationWillStart:(NSString *)animationID context:(void *)context
    82 {
    83     NSLog(@"animationID = %@,context = %@",animationID,context);
    84 }
    85 
    86 -(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    87 {
    88     NSLog(@"animationID = %@,context = %@",animationID,context);
    89 }
  • 相关阅读:
    QT与JavaScript互调
    How can I get an object's absolute position on the page in Javascript?
    ollicle.com: Biggerlink – jQuery plugin
    Javascript: Let user select an HTML element like Firebug?综述
    josscrowcroft / Simple-JavaScript-DOM-Inspector
    Advanced Customization of the jQuery Mobile Buttons | Appcropolis
    jquery-plugin-biggerLink,highLight-层加亮_andy 阳光生活_百度空间
    Highlight On Mouseover Effect With JQuery
    Quick Tip: Outline Elements on Hover
    How to get the xpath by clicking an html element
  • 原文地址:https://www.cnblogs.com/DevinSMR/p/5342626.html
Copyright © 2011-2022 走看看