Code Monkey home page Code Monkey logo

ojnotificationdemo's Introduction

OJNotification

codebeat badge

模仿 iOS 10 系统通知样式,创建可以在程序内弹出的通知样式。效果如下:

Figure

Usage

简单使用

展示最基础的模型,没有指定任何 model (项目中不建议依次方式运行,仅在测试显示效果时使用,程序没有对nil进行强制校验

[OJNotificationWindow showNotificationWithModel:nil];

传入通知模型

通知模型为 OJNotificationModel 及其子类。

创建通知模型

OJNotificationModel *notification = [[OJNotificationModel alloc] init];
notification.time = @"刚刚";
notification.title = @"用药提醒";
notification.detail = @"您预约了后天(2017年6月10日)在华西体检,请不要错过哦!";
notification.type = @"华西健康";

展示通知

[OJNotificationWindow showNotificationWithModel:notification];

TODO

  1. 屏幕旋转适配
  2. 应用数据模型
  3. 开放API,可轻松自定义自己的通知视图

ojnotificationdemo's People

Contributors

juwencheng avatar owenju avatar

Watchers

 avatar  avatar

ojnotificationdemo's Issues

无法为 content 添加滑动事件

遇到个很奇怪的问题,死活没法把滑动事件绑定到 content 上。

找了很久才发现是 UIWindowrootViewController 导致的问题。默认情况下 UIWindow 会显示 rootViewControllerview ,并且是置顶的。所以事件始终无法传递到 content 。只能绑定到 window 上。

view 隐藏即可解决。

这里提供了另外一种思路,即把 content 添加到 rootViewController.view 上。

更新 UIVisualEffectView 和 content 的约束规则

现在 UIVisualEffectView 的约束规则是 top left bottom rightcontent 一样的。如果更新 content 的约束处理滑动位移,UIVisualEffectView 也会跟着移动。不是预期效果。

如何解决

UIVisualEffectView 的修改

由于这个视图创建之后不需要左右移动,只需跟随 content 上下移动,因此把 left right 约束条件修改为和 selfwindowleft right 保持一致即可

content 修改

两种方法解决,

  1. 修改 content 左右的约束条件为 left width 的条件,即约束 content 的左边或者右边,并且指定宽度,可以做出和现在一样的效果。滑动时,修改左或右的约束值,即可实现滑动效果。缺点是屏幕旋转之后,需要重新计算 width ,更新约束值。

  2. 保持 content 左右的约束条件,滑动时,同时修改左右的约束值实现滑动效果。

创建 CocoaPods 软件库

创建CocoaPods 软件库。每次弄的时候都不顺利,这次把详细步骤记录下来,希望以后就不要这么麻烦了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.