иногда, когда мне лень использовать другие библиотеки, я просто делаю это:
// create a custom black view
UIView *overlayView = [[UIView alloc] initWithFrame:self.navigationController.view.frame];
overlayView.backgroundColor = [UIColor blackColor];
overlayView.alpha = 0.8;
overlayView.tag = 88;
// create a label
UILabel *message = [[UILabel alloc] initWithFrame:self.navigationController.view.frame];
[message setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:25.0f]];
message.text = @"message to my dear user";
message.textColor = [UIColor whiteColor];
message.textAlignment = NSTextAlignmentCenter;
message.tag = 99;
// and just add them to navigationbar view
[self.navigationController.view addSubview:overlayView];
[self.navigationController.view addSubview:message];
и затем вызываю метод, который находит эти представления, затемняет их и удаляет их:
-(void) removeOverlayViews{
UIView *view = (UIView *)[self.navigationController.view viewWithTag:88];
UILabel *label = (UILabel *)[self.navigationController.view viewWithTag:99];
[UIView animateWithDuration:0.5
animations:^{
view.alpha = 0.0;
label.alpha = 0.0;
}
completion:^(BOOL finished){
[view removeFromSuperview];
[label removeFromSuperview];
}
];
}
иногда я просто хочу показать сообщение на несколько секунд, поэтому я вызываю его сразу после добавления наложенных представлений в navigationController:
[self performSelector:@selector(removeOverlayViews) withObject:nil afterDelay:4];