[Cpp]
//
// ABCustomAlertView. h
// KnowledgeChoice
//
// Created by on 13-6-19.
// Copyright (c) 2013 DoubleMan. All rights reserved.
// You can use custom controls and proxies ..
# Import <UIKit/UIKit. h>
@ Interface ABCustomAlertView: UIWindow
// Display
-(Void) show;
// Disappear
-(Void) dismiss;
@ End
//
// ABCustomAlertView. h
// KnowledgeChoice
//
// Created by on 13-6-19.
// Copyright (c) 2013 DoubleMan. All rights reserved.
// You can use custom controls and proxies ..
# Import <UIKit/UIKit. h>
@ Interface ABCustomAlertView: UIWindow
// Display
-(Void) show;
// Disappear
-(Void) dismiss;
@ End
[Cpp]
//
// ABCustomAlertView. m
// KnowledgeChoice
//
// Created by on 13-6-19.
// Copyright (c) 2013 DoubleMan. All rights reserved.
//
# Import "ABCustomAlertView. h"
@ Implementation ABCustomAlertView
-(Id) initWithFrame :( CGRect) frame
{
Self = [super initWithFrame: frame];
If (self ){
// Initialization code
Self. windowLevel = UIWindowLevelAlert;
// Here, the alpha attribute of UIWindow cannot be set, which will affect the transparency of the sub-view. Here we use a transparent image.
// Sets the shadow to be translucent.
Self. backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "alert_bg.png"];
UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0,200, 80)] autorelease];
View. backgroundColor = [UIColor blackColor];
View. center = CGPointMake (160,240 );
[Self addSubview: view];
}
Return self;
}
-(Void) show {
[Self makeKeyAndVisible];
}
-(Void) dismiss {
[Self resignKeyWindow];
[Self release];
}
-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {
// Click to disappear
[Self dismiss];
}
-(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event {
}
-(Void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event {
}
@ End
//
// ABCustomAlertView. m
// KnowledgeChoice
//
// Created by on 13-6-19.
// Copyright (c) 2013 DoubleMan. All rights reserved.
//
# Import "ABCustomAlertView. h"
@ Implementation ABCustomAlertView
-(Id) initWithFrame :( CGRect) frame
{
Self = [super initWithFrame: frame];
If (self ){
// Initialization code
Self. windowLevel = UIWindowLevelAlert;
// Here, the alpha attribute of UIWindow cannot be set, which will affect the transparency of the sub-view. Here we use a transparent image.
// Sets the shadow to be translucent.
Self. backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "alert_bg.png"];
UIView * view = [[UIView alloc] initWithFrame: CGRectMake (0, 0,200, 80)] autorelease];
View. backgroundColor = [UIColor blackColor];
View. center = CGPointMake (160,240 );
[Self addSubview: view];
}
Return self;
}
-(Void) show {
[Self makeKeyAndVisible];
}
-(Void) dismiss {
[Self resignKeyWindow];
[Self release];
}
-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {
// Click to disappear
[Self dismiss];
}
-(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event {
}
-(Void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event {
}
@ End
This is just the basic idea. You only need to call show and dismiss to display and disappear...