• 动画的button(按下时缩小,松开时恢复)


    #import <UIKit/UIKit.h>
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    
    @end
    #import "AppDelegate.h"
    #import "RootViewController.h"
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        
        self.window.rootViewController = [[RootViewController alloc] init];
        
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    @end
    #import <UIKit/UIKit.h>
    
    @interface RootViewController : UIViewController
    
    @end
    #import "RootViewController.h"
    @interface RootViewController ()
    {
        CGFloat buttonScale;//比例
    }
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        //初始化button
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        buttonScale = 1.0;
        button.frame = CGRectMake(100, 100, 120, 60);
        [button setTitle:@"按钮" forState:0];
        [button setBackgroundImage:[UIImage imageNamed:@"button"] forState:0];
        [button addTarget:self action:@selector(buttonDownAction:) forControlEvents:UIControlEventTouchDown];
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
        [self.view addSubview:button];
    }
    /**
     *  按钮按下时,执行的方法
     */
    - (void)buttonDownAction:(UIButton*)sender{
        CGFloat scale = buttonScale < 1.0 ? 1.0 : 0.9;
        //变小
        [UIView animateWithDuration:0.25 animations:^{
            sender.transform = CGAffineTransformMakeScale(scale, scale);
        }];
        NSLog(@"变小");
    }
    /**
     *  松开按钮时,执行的方法
     */
    - (void)buttonAction:(UIButton*)sender{
        //恢复原来的尺寸
        [UIView animateWithDuration:0.25 animations:^{
            sender.transform = CGAffineTransformMakeScale(1.0, 1.0);
        } completion:^(BOOL finished) {
            //在此执行相应操作
            NSLog(@"恢复");
        }];
    }
    
    
    @end
  • 相关阅读:
    判断大文件是否上传成功(一个大文件上传到ftp,判断是否上传完成)
    hbase的region
    把hdfs数据写入到hbase表
    eclipse和scala整合,打包配置文件及打包步骤
    sparkStreaming 读kafka的数据
    脚本put数据到hdfs
    Hive的自定义函数
    Ftp客户端需要TSL功能的文件上传
    Hive中的数据库、表、数据与HDFS的对应关系
    一文了解RPC框架原理
  • 原文地址:https://www.cnblogs.com/lantu1989/p/5435985.html
Copyright © 2020-2023  润新知