一句話實現iOS版本更新提示

在App開發過程中,難免會碰到類似于添加版本更新提示這種開發需求。如何更簡單更快捷的實現版本更新提示,便成了重中之重。本文主要介紹了如何通過一句話去快捷實現iOS版本更新提示,歡迎Star!

github地址: https://github.com/RockChanel/SELUpdateAlert

SELUpdateAlert.gif

1. 添加方式

主要通過以下兩種方式為我們的App添加版本更新提示。至于如何獲取版本號以及更新內容,例如服務器獲取或AppStore獲取方式,網上已經有很多介紹,這里就不再加以闡述。

/**
 添加版本更新提示
 
 @param version 版本號
 @param descriptions 版本更新內容(數組)
 
 descriptions 格式如 @[@"1.xxxxxx",@"2.xxxxxx"]
 */
+ (void)showUpdateAlertWithVersion:(NSString *)version Descriptions:(NSArray *)descriptions;

/**
 添加版本更新提示
 
 @param version 版本號
 @param description 版本更新內容(字符串)
 
 description 格式如 @"1.xxxxxx\n2.xxxxxx"
 */
+ (void)showUpdateAlertWithVersion:(NSString *)version Description:(NSString *)description;

調用方式如下:

/** 添加更新提示 */
//方法一:
[SELUpdateAlert showUpdateAlertWithVersion:@"1.0.0" Descriptions:@[@"1.xxxxxxxxxx",@"2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",@"3.xxxxxxxxxx",@"4.xxxxxxxxxx"]];
    
//方法二:
//[SELUpdateAlert showUpdateAlertWithVersion:@"1.0.0" Description:@"1.xxxxxxxxxx\n2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n3.xxxxxxxxx\n4.xxxxxxxxxx"];
2. 出場入場動畫實現

入場動畫:

/**
 添加Alert入場動畫
 @param alert 添加動畫的View
 */
- (void)showWithAlert:(UIView*)alert{
    
    CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    animation.duration = SELAnimationTimeInterval;
    
    NSMutableArray *values = [NSMutableArray array];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    animation.values = values;
    [alert.layer addAnimation:animation forKey:nil];
}

出場動畫:

/** 添加Alert出場動畫 */
- (void)dismissAlert{
    
    [UIView animateWithDuration:SELAnimationTimeInterval animations:^{
        self.transform = (CGAffineTransformMakeScale(1.5, 1.5));
        self.backgroundColor = [UIColor clearColor];
        self.alpha = 0;
    }completion:^(BOOL finished) {
        [self removeFromSuperview];
    } ];
}
3. 修改App id

在點擊更新跳轉AppStore,需要跳轉自己應用在AppStore頁面,需要自己去設置App id.

/** App id */
#define APP_ID @"11111111"


/** 更新按鈕點擊事件 跳轉AppStore更新 */
- (void)updateVersion
{
    NSString *str = [NSString stringWithFormat:@"http://itunes.apple.com/us/app/id%@", APP_ID];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 發現 關注 消息 iOS 第三方庫、插件、知名博客總結 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,232評論 4 61
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,284評論 25 708
  • 我本不知喜歡是什么滋味 當我喜歡你的那一刻 我拿余生發誓 后半生 你只要貌美如花 我為你征服天下
    小仕不曉閱讀 147評論 0 2
  • 仝先生和我說,過了農歷年,他要跟隨老領導去一個縣城工作。 我在做飯,手一抖,鹽放了滿勺。 他去了縣城,那我呢? 仝...
    吉鈺呀閱讀 493評論 0 0
  • 中午去做了一個肩頸,脖子沉重酸痛,已經不舒服了很久。總是沒時間沒時間,于是一拖再拖,直到今天,給我按摩的姑娘...
    Always十月閱讀 235評論 5 1