Tuesday, July 16, 2013

resize iPad

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    smokeKillYou = [[UILabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 108 , self.view.frame.size.width, 108)];
    smokeKillYou.numberOfLines = 1;
    smokeKillYou.font = [UIFont fontWithName:@"Arial" size:100];
    smokeKillYou.textColor = [UIColor blackColor];
#warning шрифт не тот
    smokeKillYou.text = @"TEST";
    smokeKillYou.textAlignment = NSTextAlignmentCenter;
//    smokeKillYou.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:smokeKillYou];
    [smokeKillYou release];
    }



-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

    [self resizeWithInterfaceOrientation:toInterfaceOrientation];
}

- (void) resizeWithInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
    CGFloat width = UIInterfaceOrientationIsLandscape(interfaceOrientation)? 1024 : 768;
    CGFloat height = UIInterfaceOrientationIsLandscape(interfaceOrientation)? 768 : 1024;
    
    smokeKillYou.frame = CGRectMake(0, height - 108 , width, 108);

}

No comments:

Post a Comment