iOS 模仿蘋果官方本地通知

圖片發(fā)自簡書App

二話不說,先上代碼,下午我再娓娓道來實現(xiàn)方法吧
.h

//
//  SecondViewController.h
//  NotificationAnimationView
//
//  Created by xiāo yáng on 2019/8/8.
//  Copyright ? 2019 ccb. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController


@end


.m

//
//  SecondViewController.m
//  NotificationAnimationView
//
//  Created by xiāo yáng on 2019/8/8.
//  Copyright ? 2019 ccb. All rights reserved.
//

#import "SecondViewController.h"
#import "NotificationAnimationView.h"

@interface SecondViewController ()<NotificationAnimationViewDelegate>
@property (nonatomic , strong) NotificationAnimationView *notificationAnimationView;
@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor systemGreenColor];
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    if (!_notificationAnimationView) {
        _notificationAnimationView = [[NotificationAnimationView alloc]initWithEffect:effect];
    }
    _notificationAnimationView.delegate=self;
    [self.view addSubview:_notificationAnimationView];
    
    // Do any additional setup after loading the view.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.notificationAnimationView ShowNoticeAnimationView:@"蘋果官方通知" NoticeContent:@"你好,你做的通知和我們的通知相似度接近100%,中國民生銀行,招商銀行,河北銀行,包商銀行,大家保險以及21世紀不動產送來賀電!" AnimationTime:4.0 FixedHeight:YES];
    });
    
}
#pragma mark - delegate
-(void)StartNotificationAnimation
{
    NSLog(@"+++++++++++++++++++++++");
}
-(void)EndNotificationAnimation
{
    NSLog(@"-----------------------");
}
@end

詳情請走GitHub,記得先給我星星?,在看我的源代碼
https://github.com/xiaoyang-iOS/NotificationAnimationView.git

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內容