Friday 21 December 2012

In View, Add a Another View (Animation)

.h File

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    IBOutlet UIView *popupview;
    
    CGRect PopAnimateStart;
    CGRect PopAnimateEnd;
    
    IBOutlet UILabel *myTitle;
    IBOutlet UILabel *Contents;
}

@property(nonatomic,retain)IBOutlet UILabel *myTitle;
@property(nonatomic,retain)IBOutlet UILabel *Contents;

-(IBAction)show:(id)sender;

-(IBAction)hide:(id)sender;

@end



.m File

#import "ViewController.h"
#import "DetailPage.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize myTitle,Contents;


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title=@"Add a View in Animated View";
    
// Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)show:(id)sender
{
    myTitle.text=@"AssHuss";
    [popupview addSubview:myTitle];

     Contents.text=@"Advertisment or Somthing display contents";
    [popupview addSubview:Contents];
    
    popupview.frame=CGRectMake(0, 354, 320, 62);
    [self.view addSubview:popupview];
    
    PopAnimateStart=CGRectMake(0, 480, 320, 62);
    PopAnimateEnd=CGRectMake(0, 354, 320, 62);

    popupview.frame = PopAnimateStart;
    popupview.alpha = 1.0f;
    [UIView animateWithDuration:0.20 delay:0.1f options:UIViewAnimationCurveEaseOut animations:^{popupview.frame = PopAnimateEnd;} completion:^(BOOL finished){ }];
}

-(IBAction)detail:(id)sender
{
    DetailPage *detail=[[DetailPage alloc]init];
    [self.navigationController pushViewController:detail animated:YES];
}

-(IBAction)hide:(id)sender
{
    [popupview removeFromSuperview];
}

@end


.Xib File


Output:


    
1)click the show button.                                  2)In Bottom Shows the Another View.
                                                                                       3) Click "X" button to Close the View.
                                                                4) If you Want DetailView Press the Detail Disclosure Button.



No comments: