iapp如何制作d窗公告

iapp如何制作d窗公告,第1张

教程iapp】通知栏制作教程①

+关注学渣,1级 楼主

发表于2018-10-153476次阅读 玩机美化 〉

小白易学

超级简单

教程开始!

首先需要准备的工具:iapp(别问我为什么需要这个,我也不知道)

功能简介:每次进入软件都会跳出通知栏提醒用户!

s id = 2977

//通知id,很重要,如果不懂不要删除!

cls("android.app.Notification$Builder",通知类)

java(通知管理器,activity,"android.content.Context.getSystemService","String","notification")

javanew(通知,通知类,"Context",activity)

javax(通知,通知,通知类,"setSmallIcon","int",17301651)

//设置小图标(不设置大图就是大图标)

javax(通知,通知,通知类,"setContentTitle","CharSequence","iAPP通知栏")

//设置标题

javax(通知,通知,通知类,"setContentText","CharSequence","欢迎你的使用!希望本教程能给你带来帮助!")

//设置内容

javax(通知,通知,通知类,"setTicker","CharSequence","")

javax(通知,通知,通知类,"setAutoCancel","boolean",true)

javax(通知,通知,通知类,"setDefaults","int",-1)

//设置通知提示模式,-1所有都使用默认,1系统默认响铃,2系统默认震动,4系统默认闪光(部分手机不支持)

time(4,时间戳)

javax(通知,通知,通知类,"setWhen","long",时间戳)

javax(通知对象,通知,通知类,"build")

java(null,通知管理器,"android.app.NotificationManager.notify","int",id,"android.app.Notification",通知对象)

最佳答案: ①设置btn图片setImage,然后将btn的size设置的比图片大

②在btn上添加一个比较大的透明btn

但以上有问题,若btn无图片就无法设置;添加透明btn则会改变view的层级。所以此时最好的方法是重写btn的

-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event

方法。例如:

-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{

//当前btn大小

CGRect btnBounds = self.bounds

//扩大点击区域,想缩小就将-10设为正值

btnBounds = CGRectInset(btnBounds, -, -)

//若点击的点在新的bounds里,就返回YES

return CGRectContainsPoint(btnBounds, point)

}

对CGRectInset的解释

CGRectInset(CGRect rect, CGFloat dx, CGFloat dy)作用是将rect坐标按照(dx,dy)进行平移,对size进行如下变换

新宽度 = 原宽度 - 2*dx;新高度 = 原高度 - 2*dy

即dx,dy为正,则为缩小点击范围;dx,dy为负的话,则为扩大范围

UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(, , , )]

[self.view addSubview:view1]

CGRect rect2 = CGRectInset(view1.frame, , )

UIView *view2 = [[UIView alloc]initWithFrame:rect2]

[self.view addSubview:view2]

NSLog(@"%@",NSStringFromCGRect(rect2))

结果为

//{{110, 120}, {180, 160}}

比较这两个view的frame,即可印证该结论。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/11201410.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存