Telerik blogs
What are your Alert options out there? Why is Telerik Alert the obvious choice?

Telerik Alert for iOS

Your application is almost ready. You have implemented all screens. However, there is an error coming from the server and you should display a message about it. This is a common situation, but what's the solution? You could use one of the following alternatives:

UIAlertView and UIAlertController

The good news: in iOS there is a component that shows alerts-UIAlertView. In iOS 8 it was deprecated and replaced with UIAlertController. UIAlertController has an easy-to-use block API. However, this component has two drawbacks: it is available only in iOS 8 and it can't be customized at all. You will get only the basic iOS look.

Build Your Own

This gives you complete control over the UI and behavior. However, managing view transitions is not that easy and straightforward. You should handle different cases like device rotation for example and it needs to be tested on different devices. Before you know it, you're working late and the final deadline is coming.

Use an Open Source Component

There are many open source alternatives. Some of them look good, almost. Most often, those components are built for specific purpose and there is no documentation. When you start using them, you find that in order to get the necessary look and behavior, you should combine at least two different components. You start thinking about creating your own alert from scratch.

Presenting Telerik Alert

TKAlert-Customized-sun

Telerik Alert component helps you to easily present messages of all kinds in your applications. It is a fully customizable view allowing you to show and dismiss it with various preset animations. You can embed any kind of content in its resizable content area. Unlike most of the Alert components out there, Telerik Alert supports device rotation.

Telerik Alert is easy to use, with only a few lines of code you can change the appear animation and customize its look:
TKAlert *alert = [TKAlert new];
     
alert.title = @"Warning";
alert.message = @"Are you ready for TKAlert?";
alert.style.appearAnimation = TKAlertAnimationSlideFromTop;
alert.alertView.layer.shadowOpacity = 0.6;
alert.alertView.layer.masksToBounds = NO;
  
[alert show:YES];
Adding buttons is convenient with the inline blocks API of Telerik Alert:
TKAlertAction *action = [alert addActionWithTitle:@"Yes" handler:^BOOL(TKAlert *alert, TKAlertAction* action) {
    return YES;
}];
action.backgroundColor = [UIColor colorWithRed:0.882f green:0.882f blue:0.882f alpha:1.00f];
action.titleColor = [UIColor colorWithRed:0.302f green:0.302f blue:0.302f alpha:1.00f];
action.cornerRadius = 3;
It takes only a few rows to add a custom animation with Telerik Alert and Telerik UI for iOS:
alert.delegate = self;
  
- (void)alertDidShow:(TKAlert *)alert
{
    TKView *view = [[TKView alloc] initWithFrame:CGRectMake(20, -30, 60, 60)];
    view.shape = [TKPredefinedShape shapeWithType:TKShapeTypeCircle andSize:CGSizeZero];
    view.fill = [TKSolidFill solidFillWithColor:[UIColor colorWithRed:0.961f green:0.369f blue:0.306f alpha:1.00f]];
    view.stroke = [TKStroke strokeWithColor:[UIColor whiteColor] width:3.0];
    view.transform = CGAffineTransformMakeScale(0.1, 0.1);
    [alert.alertView addSubview:view];
     
    [UIView animateWithDuration:0.7
                          delay:0.0
         usingSpringWithDamping:0.3
          initialSpringVelocity:0.2
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
                         view.transform = CGAffineTransformIdentity;
                     } completion:^(BOOL finished) {
                     }];
}

Here is the result:
TKAlert-CustomizedView

And here are all the features of Telerik Alert at a glance:
  • Device orientation change support 
  • Custom view support
    TKAlert-CustomView
  • Easy to use block API
  • Fully customizable
  • Predefined appear/dismiss animations
  • Blurred or dimmed background style 
  • Parallax effect
  • Custom frame support
  • Auto dismiss after a specified time interval
  • Swipe or pan dismiss options
  • Horizontal/vertical buttons layout
All this will be available in our new Q2 2015 release later this month. I am eager to see what you will create with it.

Happy coding!

iOS
Tsvetan Raikov image
About the Author

Tsvetan Raikov

Tsvetan is the Team Leader of the UI for iOS team. He has been part of Telerik since 2006, when he joined the company as regular developer in the WinForms team. Tsvetan made his way through all developer postions over the past few years. His addiction to the cutting edge technologies, together with the passion to develop outstanding products are what drive him forward. In his spare time Tsvetan loves biking, hiking and snowboarding. You can find Tsvetan on Twitter @tzraikov, and LinkedIn.

Comments

Comments are disabled in preview mode.