### Installing SCLAlertView via Carthage Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet provides the command for installing SCLAlertView using Carthage, a decentralized dependency manager for Cocoa. Users should add github "dogo/SCLAlertView" to their Cartfile and then run carthage update to integrate the library into their project. This method offers a simple way to manage project dependencies. ```Shell github "dogo/SCLAlertView" ``` -------------------------------- ### Example: SCLAlertView with Countdown Timer on Button Source: https://github.com/dogo/sclalertview/blob/develop/README.md This example demonstrates a complete SCLAlertView setup with a countdown timer displayed on the 'Dismiss' button. The alert has a set duration, and the timer visually indicates the remaining time until the alert automatically closes. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; [alert addTimerToButtonIndex:0 reverse:YES]; [alert showInfo:self title:@"Countdown Timer" subTitle:@"This alert has a duration set, and a countdown timer on the Dismiss button to show how long is left." closeButtonTitle:@"Dismiss" duration:10.0f]; ``` -------------------------------- ### Creating Basic Alert with Fluent API in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to create and display a basic warning alert using the fluent API style of SCLAlertView-Objective-C. It shows the use of SCLAlertViewBuilder for adding actions and SCLAlertViewShowBuilder for configuring the alert's style, title, subtitle, and duration, then presenting it on a view controller. ```Objective-C SCLAlertViewBuilder *builder = [SCLAlertViewBuilder new] .addButtonWithActionBlock(@"Send", ^{ /*work here*/ }); SCLAlertViewShowBuilder *showBuilder = [SCLAlertViewShowBuilder new] .style(SCLAlertViewStyleWarning) .title(@"Title") .subTitle(@"Subtitle") .duration(0); [showBuilder showAlertView:builder.alertView onViewController:self.window.rootViewController]; // or even showBuilder.show(builder.alertView, self.window.rootViewController); ``` -------------------------------- ### Initializing SCLAlertView in a New Window (No UIViewController) Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to initialize and display various types of SCLAlertView alerts without requiring a UIViewController. It covers standard success, error, notice, warning, info, edit, custom, waiting, and question alerts, as well as initializing the alert with a custom width. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow]; [alert showSuccess:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f]; // Alternative alert types [alert showError:@"Hello Error" subTitle:@"This is a more descriptive error text." closeButtonTitle:@"OK" duration:0.0f]; // Error [alert showNotice:@"Hello Notice" subTitle:@"This is a more descriptive notice text." closeButtonTitle:@"Done" duration:0.0f]; // Notice [alert showWarning:@"Hello Warning" subTitle:@"This is a more descriptive warning text." closeButtonTitle:@"Done" duration:0.0f]; // Warning [alert showInfo:@"Hello Info" subTitle:@"This is a more descriptive info text." closeButtonTitle:@"Done" duration:0.0f]; // Info [alert showEdit:@"Hello Edit" subTitle:@"This is a more descriptive info text with a edit textbox" closeButtonTitle:@"Done" duration:0.0f]; // Edit [alert showCustom:[UIImage imageNamed:@"git"] color:color title:@"Custom" subTitle:@"Add a custom icon and color for your own type of alert!" closeButtonTitle:@"OK" duration:0.0f]; // Custom [alert showWaiting:@"Waiting..." subTitle:@"Blah de blah de blah, blah. Blah de blah de" closeButtonTitle:nil duration:5.0f]; [alert showQuestion:@"Question?" subTitle:kSubtitle closeButtonTitle:@"Dismiss" duration:0.0f]; // Using custom alert width SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:300.0f]; ``` -------------------------------- ### Displaying Various Alert Types with Traditional API in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet showcases the traditional, easy-to-use API of SCLAlertView-Objective-C for displaying various predefined alert types such as success, error, notice, warning, info, edit, custom, waiting, and question alerts. It also demonstrates how to initialize an alert with a custom width. ```Objective-C // Get started SCLAlertView *alert = [[SCLAlertView alloc] init]; [alert showSuccess:self title:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f]; // Alternative alert types [alert showError:self title:@"Hello Error" subTitle:@"This is a more descriptive error text." closeButtonTitle:@"OK" duration:0.0f]; // Error [alert showNotice:self title:@"Hello Notice" subTitle:@"This is a more descriptive notice text." closeButtonTitle:@"Done" duration:0.0f]; // Notice [alert showWarning:self title:@"Hello Warning" subTitle:@"This is a more descriptive warning text." closeButtonTitle:@"Done" duration:0.0f]; // Warning [alert showInfo:self title:@"Hello Info" subTitle:@"This is a more descriptive info text." closeButtonTitle:@"Done" duration:0.0f]; // Info [alert showEdit:self title:@"Hello Edit" subTitle:@"This is a more descriptive info text with a edit textbox" closeButtonTitle:@"Done" duration:0.0f]; // Edit [alert showCustom:self image:[UIImage imageNamed:@"git"] color:color title:@"Custom" subTitle:@"Add a custom icon and color for your own type of alert!" closeButtonTitle:@"OK" duration:0.0f]; // Custom [alert showWaiting:self title:@"Waiting..." subTitle:@"Blah de blah de blah, blah. Blah de blah de" closeButtonTitle:nil duration:5.0f]; [alert showQuestion:self title:@"Question?" subTitle:kSubtitle closeButtonTitle:@"Dismiss" duration:0.0f]; // Using custom alert width SCLAlertView *alert = [[SCLAlertView alloc] initWithWindowWidth:300.0f]; ``` -------------------------------- ### Configuring SCLAlertView Properties in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet showcases various properties available for customizing the appearance and behavior of an SCLAlertView. It covers options like dismissing on tap outside, setting show/hide animation types, background styles, custom colors for views and icons, corner radius, and integrating sound effects. These properties provide extensive control over the alert's presentation. ```Objective-C //Dismiss on tap outside (Default is NO) alert.shouldDismissOnTapOutside = YES; //Hide animation type (Default is SCLAlertViewHideAnimationFadeOut) alert.hideAnimationType = SCLAlertViewHideAnimationSlideOutToBottom; //Show animation type (Default is SCLAlertViewShowAnimationSlideInFromTop) alert.showAnimationType = SCLAlertViewShowAnimationSlideInFromLeft; //Set background type (Default is SCLAlertViewBackgroundShadow) alert.backgroundType = SCLAlertViewBackgroundBlur; //Overwrite SCLAlertView (Buttons, top circle and borders) colors alert.customViewColor = [UIColor purpleColor]; //Set custom tint color for icon image. alert.iconTintColor = [UIColor purpleColor]; //Override top circle tint color with background color alert.tintTopCircle = NO; //Set custom corner radius for SCLAlertView alert.cornerRadius = 13.0f; //Overwrite SCLAlertView background color alert.backgroundViewColor = [UIColor cyanColor]; //Returns if the alert is visible or not. alert.isVisible; //Make the top circle icon larger alert.useLargerIcon = YES; //Using sound alert.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/right_answer.mp3", [[NSBundle mainBundle] resourcePath]]]; ``` -------------------------------- ### Adding a Switch Button to SCLAlertView Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to add a custom `SCLSwitchView` to an SCLAlertView. It shows how to configure the switch's label and tint color, and how to retrieve its selected state when a button on the alert is pressed. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; SCLSwitchView *switchView = [alert addSwitchViewWithLabel:@"Don't show again".uppercaseString]; switchView.tintColor = [UIColor brownColor]; [alert addButton:@"Done" actionBlock:^(void) { NSLog(@"Show again? %@", switchView.isSelected ? @"-No": @"-Yes"); }]; [alert showCustom:self image:[UIImage imageNamed:@"switch"] color:[UIColor brownColor] title:kInfoTitle subTitle:kSubtitle closeButtonTitle:nil duration:0.0f]; ``` -------------------------------- ### Adding Buttons to SCLAlertView Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet illustrates how to add interactive buttons to an SCLAlertView. It demonstrates three methods: using a selector, using a simple action block, and using a validation block combined with an action block for conditional execution. The alert is then displayed with these added buttons. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; //Using Selector [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; //Using Block [alert addButton:@"Second Button" actionBlock:^(void) { NSLog(@"Second button tapped"); }]; //Using Blocks With Validation [alert addButton:@"Validate" validationBlock:^BOOL { BOOL passedValidation = ....; return passedValidation; } actionBlock:^{ // handle successful validation here }]; [alert showSuccess:self title:@"Button View" subTitle:@"This alert view has buttons" closeButtonTitle:@"Done" duration:0.0f]; ``` -------------------------------- ### Creating Complex Alert with Fluent API and Text Field in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet illustrates how to construct a more complex custom alert using the fluent API, including a text field for user input and a validation block for a button. It configures animation types, adds a text field with a title, and a 'Done' button with validation and action blocks, then displays a custom-styled alert with an image and color. ```Objective-C NSString *title = @"Title"; NSString *message = @"Message"; NSString *cancel = @"Cancel"; NSString *done = @"Done"; SCLALertViewTextFieldBuilder *textField = [SCLALertViewTextFieldBuilder new].title(@"Code"); SCLALertViewButtonBuilder *doneButton = [SCLALertViewButtonBuilder new].title(done) .validationBlock(^BOOL{ NSString *code = [textField.textField.text copy]; return [code isVisible]; }) .actionBlock(^{ NSString *code = [textField.textField.text copy]; [self confirmPhoneNumberWithCode:code]; }); SCLAlertViewBuilder *builder = [SCLAlertViewBuilder new] .showAnimationType(SCLAlertViewShowAnimationFadeIn) .hideAnimationType(SCLAlertViewHideAnimationFadeOut) .shouldDismissOnTapOutside(NO) .addTextFieldWithBuilder(textField) .addButtonWithBuilder(doneButton); SCLAlertViewShowBuilder *showBuilder = [SCLAlertViewShowBuilder new] .style(SCLAlertViewStyleCustom) .image([SCLAlertViewStyleKit imageOfInfo]) .color([UIColor blueColor]) .title(title) .subTitle(message) .closeButtonTitle(cancel) .duration(0.0f); [showBuilder showAlertView:builder.alertView onViewController:self]; ``` -------------------------------- ### Adding Custom View to SCLAlertView in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to create and add a custom UIView to an SCLAlertView instance. It initializes an alert, creates a red-colored custom view, adds it to the alert, and then displays a notice alert with the integrated custom view. This allows for highly customized alert content beyond standard text. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 215.0f, 80.0f)]; customView.backgroundColor = [UIColor redColor]; [alert addCustomView:customView]; [alert showNotice:self title:@"Title" subTitle:@"This alert view shows a custom view" closeButtonTitle:@"Done" duration:0.0f]; ``` -------------------------------- ### Displaying Indeterminate Progress with SCLAlertView Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet shows how to display an SCLAlertView that indicates an indeterminate waiting or loading state. The alert is configured with a title, subtitle, and a duration, but without a close button, implying a process that needs to complete before dismissal. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; [alert showWaiting:self title:@"Waiting..." subTitle:@"Blah de blah de blah, blah. Blah de blah de" closeButtonTitle:nil duration:5.0f]; ``` -------------------------------- ### Adding a Text Field to SCLAlertView Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to integrate a text input field into an SCLAlertView. It shows how to add a `UITextField` to the alert, set a placeholder, and then retrieve the entered text when a custom button is tapped. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; UITextField *textField = [alert addTextField:@"Enter your name" setDefaultText:nil]; [alert addButton:@"Show Name" actionBlock:^(void) { NSLog(@"Text value: %@", textField.text); }]; [alert showEdit:self title:@"Edit View" subTitle:@"This alert view shows a text box" closeButtonTitle:@"Done" duration:0.0f]; ``` -------------------------------- ### SCLAlertView Show Animation Styles in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This typedef NS_ENUM defines the various animation types available when an SCLAlertView is presented. Options include fading in, sliding in from different directions (bottom, top, left, right, center), or simply appearing. These animations provide visual feedback during the alert's presentation, enhancing the user experience. ```Objective-C typedef NS_ENUM(NSInteger, SCLAlertViewShowAnimation) { SCLAlertViewShowAnimationFadeIn, SCLAlertViewShowAnimationSlideInFromBottom, SCLAlertViewShowAnimationSlideInFromTop, SCLAlertViewShowAnimationSlideInFromLeft, SCLAlertViewShowAnimationSlideInFromRight, SCLAlertViewShowAnimationSlideInFromCenter, SCLAlertViewShowAnimationSlideInToCenter, SCLAlertViewShowAnimationSimplyAppear }; ``` -------------------------------- ### SCLAlertView Style Enumeration in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This typedef NS_ENUM defines the available styles for SCLAlertView, each corresponding to a distinct visual theme and icon. Developers can choose from styles like Success, Error, Notice, Warning, Info, Edit, Waiting, Question, and Custom to convey different types of messages. These styles dictate the default appearance of the alert's top circle and icon. ```Objective-C typedef NS_ENUM(NSInteger, SCLAlertViewStyle) { SCLAlertViewStyleSuccess, SCLAlertViewStyleError, SCLAlertViewStyleNotice, SCLAlertViewStyleWarning, SCLAlertViewStyleInfo, SCLAlertViewStyleEdit, SCLAlertViewStyleWaiting, SCLAlertViewStyleQuestion, SCLAlertViewStyleCustom }; ``` -------------------------------- ### Handling SCLAlertView Dismissal in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to register a block to be executed when an SCLAlertView is dismissed. The alertIsDismissed: method allows developers to perform actions, such as logging or updating UI, immediately after the alert view disappears from the screen. This is useful for post-dismissal logic. ```Objective-C //Receiving information that SCLAlertView is dismissed [alert alertIsDismissed:^{ NSLog(@"SCLAlertView dismissed!"); }]; ``` -------------------------------- ### SCLAlertView Background Styles in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This typedef NS_ENUM defines the different background styles that can be applied to an SCLAlertView. Options include a shadow effect, a blur effect, or a transparent background. These styles control the visual appearance of the area behind the alert, allowing for integration with various UI designs. ```Objective-C typedef NS_ENUM(NSInteger, SCLAlertViewBackground) { SCLAlertViewBackgroundShadow, SCLAlertViewBackgroundBlur, SCLAlertViewBackgroundTransparent }; ``` -------------------------------- ### Adding a Timer to an SCLAlertView Button Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet shows how to add a countdown timer display to a specific button within an SCLAlertView. The `addTimerToButtonIndex:reverse:` method allows specifying the button by its index and whether the timer should count up or down. ```Objective-C //The index of the button to add the timer display to. [alert addTimerToButtonIndex:0 reverse:NO]; ``` -------------------------------- ### Adding Text Attributes to SCLAlertView Subtitle Source: https://github.com/dogo/sclalertview/blob/develop/README.md This snippet demonstrates how to apply custom text attributes to the subtitle of an SCLAlertView using `attributedFormatBlock`. It shows how to change text color and add an underline to specific words within the subtitle string, providing enhanced visual styling. ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; alert.attributedFormatBlock = ^NSAttributedString* (NSString *value) { NSMutableAttributedString *subTitle = [[NSMutableAttributedString alloc]initWithString:value]; NSRange redRange = [value rangeOfString:@"Attributed" options:NSCaseInsensitiveSearch]; [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; NSRange greenRange = [value rangeOfString:@"successfully" options:NSCaseInsensitiveSearch]; [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:greenRange]; NSRange underline = [value rangeOfString:@"completed" options:NSCaseInsensitiveSearch]; [subTitle addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)} range:underline]; return subTitle; }; [alert showSuccess:self title:@"Button View" subTitle:@"Attributed string operation successfully completed." closeButtonTitle:@"Done" duration:0.0f]; ``` -------------------------------- ### SCLAlertView Hide Animation Styles in Objective-C Source: https://github.com/dogo/sclalertview/blob/develop/README.md This typedef NS_ENUM defines the various animation types available when an SCLAlertView is dismissed. Options include fading out, sliding out in different directions (bottom, top, left, right, center), or simply disappearing. These animations provide visual feedback during the alert's dismissal, enhancing the user experience. ```Objective-C typedef NS_ENUM(NSInteger, SCLAlertViewHideAnimation) { SCLAlertViewHideAnimationFadeOut, SCLAlertViewHideAnimationSlideOutToBottom, SCLAlertViewHideAnimationSlideOutToTop, SCLAlertViewHideAnimationSlideOutToLeft, SCLAlertViewHideAnimationSlideOutToRight, SCLAlertViewHideAnimationSlideOutToCenter, SCLAlertViewHideAnimationSlideOutFromCenter, SCLAlertViewHideAnimationSimplyDisappear }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.