반응형
    
    
    
  iOS에서도 Android의 Toast같은 형태로 메세지를 보여주는 일이 많습니다.
Apple에서 제공하는 기능이 없어서 직접 구현해 보았습니다.
기본 사용 방법은 다음과 같습니다.
- 기본 애니메이션
- 기본 출력시간
[[ChopeToastView ToastViewWithMessage:@"TEST"] show];
보여지는 시간을 지정할 수 있습니다.
- 기본 애니메이션
[[ChopeToastView ToastViewWithMessage:@"TEST"] showWithDuration:1.0];
애니메이션 지정도 가능합니다.
[[ChopeToastView ToastViewWithMessage:@"TEST"] showWithAnimation:^(ChopeToastView *toastView) {
    CGFloat y = toastView.frame.origin.y;
    
    CGRect frame = toastView.frame;
    frame.origin.y = -1 * toastView.frame.size.height;
    toastView.frame = frame;
    
    [UIView animateWithDuration:0.5
                     animations:^{
                         CGRect frame = toastView.frame;
                         frame.origin.y = y;
                         toastView.frame = frame;
                     }
                     completion:^(BOOL finished) {
                         [UIView animateWithDuration:0.5
                                               delay:3.0
                                             options:UIViewAnimationOptionTransitionNone
                                          animations:^{
                                              CGRect frame = toastView.frame;
                                              frame.origin.y +=  toastView.frame.size.height;
                                              toastView.frame = frame;
                                          }
                                          completion:^(BOOL finished) {
                                              [toastView hide];
                                          }];
                     }];
}];
이밖에도 여러가지 스타일을 지정할 수 있습니다.
현재까지 제공하는것으로는....
- font
- textColor
- backgroundColor
- backgroundAlpha
- padding
- margin
- roundRadius
UIAppearance도 적용해 보려고 했지만... 빨리 올리고 싶었기 때문에... 시간 관계상 다음으로... :)
반응형
    
    
    
  'Project > OpenSource' 카테고리의 다른 글
| [ChopeTableController] v0.3.0 (0) | 2014.07.22 | 
|---|---|
| ChopeTableController (0) | 2014.06.06 | 
| ChopeToastView v0.1.1 (0) | 2014.01.22 |