2014년 2월 26일 수요일

hexa 값으로 컬러값 한번에 설정


RGB hexa 값(0xfffefa)으로 RGB값 설정 예제)

    unsigned rgbValue = 0xfffefa;
    UIColor *bgColor = [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0
                                       green:((rgbValue & 0xFF00) >> 8)/255.0
                                        blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
    [myView setBackgroundColor:bgColor];

2014년 2월 21일 금요일

Animation 2


방법 1)

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                           forView:newView
                             cache:YES];
    [containerView setHidden:NO];
    [containerView addSubview:newView];
    [UIView commitAnimations];


방법 2)
    [UIView transitionWithView: containerView duration:0.5
                       options:UIViewAnimationOptionCurveEaseInOut 
                    animations:^ {
                        [containerView addSubview:newView];
                    } completion:nil];



방법 3)
CATransition *animation = [CATransition animation];
[animation setDuration:0.2];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromRight];
    [newView.layer addAnimation:animation forKey:nil];
    [containerView addSubview:newView];

remove subview

CATransition *animation = [CATransition animation];
            [animation setDuration:0.5];
            [animation setType:kCATransitionReveal];
            [animation setSubtype:kCATransitionFromLeft];
            [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
            [[_refMenuContainerView layer] addAnimation:animation forKey:@"SlideView"]; //@"SwitchToNewView" , kCATransition ,,,,
            

            [subview removeFromSuperview];

2014년 2월 16일 일요일

UINavigationController 에서 뒤로(BACK) 두번 하기 (Pop)

popToViewController를 사용 하면 됨.



int viewControllerStackCount = self.navigationController.viewControllers.count;

    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:(viewControllerStackCount-3)] animated:YES];

2014년 2월 14일 금요일

Animation

1. UINavigationController에 present & dismiss animation 적용

////// presentedViewController animation

CATransition* transition = [CATransition animation];
    transition.duration = 0.5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromTop;
    [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
    
    BoolshelfSubViewController *controller= [self.storyboard instantiateViewControllerWithIdentifier:@"BoolshelfSubViewController"];

    [self.navigationController pushViewController:controller animated:NO];
   

////// dismissViewControllerAnimated animation

CATransition* transition = [CATransition animation];
    transition.duration = 0.5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionReveal;
    transition.subtype = kCATransitionFromBottom;
    [self.navigationController.view.layer addAnimation:transition forKey:nil];

    [[self navigationController] popViewControllerAnimated:NO];


2.  UIView를 이용한 animation 적용

[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView setAnimationDuration:0.7];

[self.navigationController pushViewController:pageViewController animated:NO];
pageViewController = nil;
    
[UIView commitAnimations];


3. UIView Layer에 animation 적용 


CATransition *animation = [CATransition animation];
[animation setDuration:0.2];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromRight];
    [menuView.layer addAnimation:animation forKey:nil];

    [_menuContainerView addSubview:menuView];