AlertView动画

简介:

AlertView动画

 

效果

 

源码

https://github.com/YouXianMing/Animations



//
//  AbstractAlertView.h
//  Animations
//
//  Created by YouXianMing on 16/1/2.
//  Copyright © 2016年 YouXianMing. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class AbstractAlertView;

@protocol AbstractAlertViewDelegate <NSObject>

/**
 *  The AlertView's event.
 *
 *  @param alertView The AlertViewProtocol object.
 *  @param event     Event data.
 *  @param index     Event index.
 */
- (void)alertView:(AbstractAlertView *)alertView data:(id)data atIndex:(NSInteger)index;

@end

@interface AbstractAlertView : UIView

/**
 *  The AlertView event delegate.
 */
@property (nonatomic, weak)   id <AbstractAlertViewDelegate> delegate;

/**
 *  The title, default is nil.
 */
@property (nonatomic, strong) NSString  *title;

/**
 *  The subtitle, default is nil.
 */
@property (nonatomic, strong) NSString  *subTitle;

/**
 *  The message, default is nil.
 */
@property (nonatomic, strong) NSString  *message;

/**
 *  Button's title array, default is nil.
 */
@property (nonatomic, strong) NSArray   <NSString *>  *buttonsTitle;

/**
 *  The contentView.
 */
@property (nonatomic, weak)   UIView    *contentView;

/**
 *  Auto hiden or not, default is NO.
 */
@property (nonatomic)         BOOL       autoHiden;

/**
 *  If The autoHiden is YES, you should set the delay hiden duration, default is 2.0.
 */
@property (nonatomic)         NSTimeInterval    delayAutoHidenDuration;

/**
 *  Show the AlertView.
 */
- (void)show;

/**
 *  Hide the AlertView.
 */
- (void)hide;

/**
 *  Store View with key.
 *
 *  @param view View.
 *  @param key  Key.
 */
- (void)setView:(UIView *)view ForKey:(NSString *)key;

/**
 *  Get View with key.
 *
 *  @param key Key.
 *
 *  @return View.
 */
- (UIView *)viewWithKey:(NSString *)key;

@end


//
//  AbstractAlertView.m
//  Animations
//
//  Created by YouXianMing on 16/1/2.
//  Copyright © 2016年 YouXianMing. All rights reserved.
//

#import "AbstractAlertView.h"


@interface AbstractAlertView ()

@property (nonatomic, strong) NSMapTable  *mapTable;

@end

@implementation AbstractAlertView

- (instancetype)init {
    
    if (self = [super init]) {
        
        self.delayAutoHidenDuration = 2.f;
        self.autoHiden              = NO;
        self.mapTable               = [NSMapTable strongToWeakObjectsMapTable];
    }
    
    return self;
}

- (void)show {
    
    [NSException raise:@"AlertViewProtocol"
                format:@"Cannot use show method from subclass."];
}

- (void)hide {
    
    [NSException raise:@"AlertViewProtocol"
                format:@"Cannot use hide method from subclass."];
}

- (void)setView:(UIView *)view ForKey:(NSString *)key {

    [self.mapTable setObject:view forKey:key];
}

- (UIView *)viewWithKey:(NSString *)key {

    return [self.mapTable objectForKey:key];
}

@end

细节

动画效果是基于一个抽象的基类实现的。


目录
相关文章
|
7月前
|
iOS开发 UED 容器
navigationController 的使用详解
navigationController 的使用详解
UIView随手指的移动
UIView随手指的移动
60 0
使用requestAnimationFrame实现进度条
使用requestAnimationFrame实现进度条
169 0
CABasicAnimation旋转动画
CABasicAnimation旋转动画
188 0
CABasicAnimation旋转动画
|
XML Android开发 数据格式
动画必须有(一): 属性动画浅谈
目录 前言 ObjectAnimator的初步使用 用AnimatorSet进行动画混合 将动画写在xml中 动画监听 ViewPropertyAnimator上手 最后 前言 官方文档传送门 属性动画是非常非常好用的, 谷歌自己都说这是一个强大的框架.
1242 0
|
XML Android开发 数据格式
|
XML Android开发 数据格式
Android动画Frame Animation 帧动画
//=================【frame animation 帧动画】=============================== Frame动画是一系列图片按照一定的顺序展示的过程,和放电影的机制很相似,我们称为逐帧动画。 Frame动画可以被定义在XML文件中,也可以完全编码实现。 实现方法两种: 1)xml中的实现方法在/res下的anim或drawable目
1554 0