欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android 自定义弹出框实现代码

程序员文章站 2024-03-06 12:54:14
废话不多说了,直接给大家上关键代码了。 - (void)viewdidload { [super viewdidload]; // do any addit...

废话不多说了,直接给大家上关键代码了。

- (void)viewdidload
{
[super viewdidload];
// do any additional setup after loading the view.
[self showalertview:@"11111"];
}
//自定义弹出框
-(void)showalertview:(nsstring *)strtiptext
{
uiview *showview=[[uiview alloc]init];
[showview setframe:cgrectmake(100, 100, 120, 35)];
[showview setalpha:0.0f];
[showview setbackgroundcolor:[uicolor blackcolor]];
[showview setclipstobounds:yes];
[[showview layer]setmaskstobounds:yes];
[[showview layer]setcornerradius:5.0f];
uilabel *lbltips=[[uilabel alloc]init];
[lbltips setframe:cgrectmake(0, 0, 120, 35)];
[lbltips settext:strtiptext];
[lbltips settextalignment:nstextalignmentcenter];
[lbltips settextcolor:[uicolor whitecolor]];
[lbltips setbackgroundcolor:[uicolor clearcolor]];
[lbltips setfont:[uifont boldsystemfontofsize:16]];
[showview addsubview:lbltips];
[self.view addsubview:showview];
[uiview animatewithduration:0.5f delay:0.0f options:uiviewanimationoptioncurvelinear animations:^{
showview.alpha=1.0f;
}completion:^(bool finished){
[uiview animatewithduration:1.0f delay:1.0f options:uiviewanimationoptioncurvelinear animations:^{
showview.alpha=0.0f;
}completion:^(bool finished){
;
}];
}];
}

以上所述是小编给大家介绍的android 自定义弹出框实现代码,希望对大家有所帮助