├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── scripts │ └── build_app.sh ├── stale.yml └── workflows │ └── Build.yml ├── .gitignore ├── .ruby-version ├── .tool-versions ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── SCLAlertView-Objective-C.podspec ├── SCLAlertView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── SCLAlertView.xcscheme │ └── SCLAlertViewFramework.xcscheme ├── SCLAlertView ├── SCLAlertView.h ├── SCLAlertView.m ├── SCLAlertViewResponder.h ├── SCLAlertViewResponder.m ├── SCLAlertViewStyleKit.h ├── SCLAlertViewStyleKit.m ├── SCLButton.h ├── SCLButton.m ├── SCLMacros.h ├── SCLSwitchView.h ├── SCLSwitchView.m ├── SCLTextView.h ├── SCLTextView.m ├── SCLTimerDisplay.h ├── SCLTimerDisplay.m ├── UIImage+ImageEffects.h └── UIImage+ImageEffects.m ├── SCLAlertViewExample ├── AppDelegate │ ├── AppDelegate.h │ └── AppDelegate.m ├── Base.lproj │ └── Storyboard.storyboard ├── Category │ ├── UIViewController+Alert.h │ └── UIViewController+Alert.m ├── Fonts │ └── comic-sans.ttf ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon_120x120-1.png │ │ ├── icon_120x120.png │ │ ├── icon_152x152.png │ │ ├── icon_167x167.png │ │ ├── icon_180x180.png │ │ ├── icon_29x29-1.png │ │ ├── icon_29x29.png │ │ ├── icon_40x40.png │ │ ├── icon_50x50.png │ │ ├── icon_50x50@2x.png │ │ ├── icon_57x57.png │ │ ├── icon_57x57@2x.png │ │ ├── icon_58x58-1.png │ │ ├── icon_58x58.png │ │ ├── icon_72x72.png │ │ ├── icon_72x72@2x.png │ │ ├── icon_76x76.png │ │ ├── icon_80x80-1.png │ │ ├── icon_80x80.png │ │ └── icon_87x87.png │ ├── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── git.imageset │ │ ├── Contents.json │ │ └── git.png │ └── switch.imageset │ │ ├── Contents.json │ │ └── switch.png ├── Info.plist ├── SCLAlertView-Objective-C-prefix.pch ├── Sounds │ └── right_answer.mp3 ├── ViewController │ ├── ViewController.h │ └── ViewController.m └── main.m ├── SCLAlertViewFramework ├── Info.plist └── SCLAlertViewFramework.h ├── SCLAlertViewTests ├── Info.plist └── SCLAlertViewTests.m └── ScreenShots ├── ScreenShot.png ├── ScreenShot2.png ├── ScreenShot3.png ├── ScreenShot4.png ├── ScreenShot5.png ├── ScreenShot6.png ├── ScreenShot7.png └── ScreenShot8.png /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Smartphone (please complete the following information):** 24 | - Device: [e.g. iPhone6] 25 | - OS: [e.g. iOS8.1] 26 | - Version [e.g. 22] 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ###### Fixes issue #. 2 | - [ ] This pull request follows the coding standards 3 | 4 | ###### This PR changes: 5 | - -------------------------------------------------------------------------------- /.github/scripts/build_app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eo pipefail 4 | 5 | xcodebuild -project SCLAlertView.xcodeproj \ 6 | -scheme SCLAlertView \ 7 | -destination platform=iOS\ Simulator,OS=17.2,name=iPhone\ 15 \ 8 | clean build | xcpretty 9 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 30 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - enhancement 8 | - bug 9 | - help wanted 10 | # Label to use when marking an issue as stale 11 | staleLabel: wontfix 12 | # Comment to post when marking an issue as stale. Set to `false` to disable 13 | markComment: > 14 | This issue has been automatically marked as stale because it has not had 15 | recent activity. It will be closed if no further activity occurs. Thank you 16 | for your contributions. 17 | # Comment to post when closing a stale issue. Set to `false` to disable 18 | closeComment: false 19 | -------------------------------------------------------------------------------- /.github/workflows/Build.yml: -------------------------------------------------------------------------------- 1 | name: Building 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | build: 6 | name: Building SCLAlertView 7 | runs-on: macos-13 8 | steps: 9 | - name: Checkout repository 10 | uses: actions/checkout@v3 11 | - name: Setup Xcode version 12 | uses: maxim-lobanov/setup-xcode@v1.6.0 13 | with: 14 | xcode-version: 15.0.1 15 | - name: Building iOS app 16 | run: exec ./.github/scripts/build_app.sh 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS 2 | .DS_Store 3 | 4 | # Xcode 5 | # 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.xcworkspacedata 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # CocoaPods 25 | # 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 29 | # 30 | # Pods/ 31 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.1.2 2 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | ruby 3.1.2 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at diautilio@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 17 | do not have permission to do that, you may request the second reviewer to merge it for you. 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | source "https://rubygems.org" 3 | 4 | ruby "3.1.2" 5 | 6 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 7 | 8 | gem "cocoapods" 9 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (3.0.6) 5 | rexml 6 | activesupport (7.1.2) 7 | base64 8 | bigdecimal 9 | concurrent-ruby (~> 1.0, >= 1.0.2) 10 | connection_pool (>= 2.2.5) 11 | drb 12 | i18n (>= 1.6, < 2) 13 | minitest (>= 5.1) 14 | mutex_m 15 | tzinfo (~> 2.0) 16 | addressable (2.8.6) 17 | public_suffix (>= 2.0.2, < 6.0) 18 | algoliasearch (1.27.5) 19 | httpclient (~> 2.8, >= 2.8.3) 20 | json (>= 1.5.1) 21 | atomos (0.1.3) 22 | base64 (0.2.0) 23 | bigdecimal (3.1.5) 24 | claide (1.1.0) 25 | cocoapods (1.14.3) 26 | addressable (~> 2.8) 27 | claide (>= 1.0.2, < 2.0) 28 | cocoapods-core (= 1.14.3) 29 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 30 | cocoapods-downloader (>= 2.1, < 3.0) 31 | cocoapods-plugins (>= 1.0.0, < 2.0) 32 | cocoapods-search (>= 1.0.0, < 2.0) 33 | cocoapods-trunk (>= 1.6.0, < 2.0) 34 | cocoapods-try (>= 1.1.0, < 2.0) 35 | colored2 (~> 3.1) 36 | escape (~> 0.0.4) 37 | fourflusher (>= 2.3.0, < 3.0) 38 | gh_inspector (~> 1.0) 39 | molinillo (~> 0.8.0) 40 | nap (~> 1.0) 41 | ruby-macho (>= 2.3.0, < 3.0) 42 | xcodeproj (>= 1.23.0, < 2.0) 43 | cocoapods-core (1.14.3) 44 | activesupport (>= 5.0, < 8) 45 | addressable (~> 2.8) 46 | algoliasearch (~> 1.0) 47 | concurrent-ruby (~> 1.1) 48 | fuzzy_match (~> 2.0.4) 49 | nap (~> 1.0) 50 | netrc (~> 0.11) 51 | public_suffix (~> 4.0) 52 | typhoeus (~> 1.0) 53 | cocoapods-deintegrate (1.0.5) 54 | cocoapods-downloader (2.1) 55 | cocoapods-plugins (1.0.0) 56 | nap 57 | cocoapods-search (1.0.1) 58 | cocoapods-trunk (1.6.0) 59 | nap (>= 0.8, < 2.0) 60 | netrc (~> 0.11) 61 | cocoapods-try (1.2.0) 62 | colored2 (3.1.2) 63 | concurrent-ruby (1.2.2) 64 | connection_pool (2.4.1) 65 | drb (2.2.0) 66 | ruby2_keywords 67 | escape (0.0.4) 68 | ethon (0.16.0) 69 | ffi (>= 1.15.0) 70 | ffi (1.16.3) 71 | fourflusher (2.3.1) 72 | fuzzy_match (2.0.4) 73 | gh_inspector (1.1.3) 74 | httpclient (2.8.3) 75 | i18n (1.14.1) 76 | concurrent-ruby (~> 1.0) 77 | json (2.7.1) 78 | minitest (5.20.0) 79 | molinillo (0.8.0) 80 | mutex_m (0.2.0) 81 | nanaimo (0.3.0) 82 | nap (1.1.0) 83 | netrc (0.11.0) 84 | public_suffix (4.0.7) 85 | rexml (3.3.9) 86 | ruby-macho (2.5.1) 87 | ruby2_keywords (0.0.5) 88 | typhoeus (1.4.1) 89 | ethon (>= 0.9.0) 90 | tzinfo (2.0.6) 91 | concurrent-ruby (~> 1.0) 92 | xcodeproj (1.25.1) 93 | CFPropertyList (>= 2.3.3, < 4.0) 94 | atomos (~> 0.1.3) 95 | claide (>= 1.0.2, < 2.0) 96 | colored2 (~> 3.1) 97 | nanaimo (~> 0.3.0) 98 | rexml (>= 3.3.6, < 4.0) 99 | 100 | PLATFORMS 101 | x86_64-darwin-23 102 | x86_64-linux 103 | 104 | DEPENDENCIES 105 | cocoapods 106 | 107 | RUBY VERSION 108 | ruby 3.1.2p20 109 | 110 | BUNDLED WITH 111 | 2.3.7 112 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2023 SCLAlertView-Objective-C by Diogo Autilio 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SCLAlertView-Objective-C 2 | ============ 3 | 4 | Animated Alert View written in Swift but ported to Objective-C, which can be used as a `UIAlertView` or `UIAlertController` replacement. 5 | 6 | ![Build Status](https://github.com/dogo/SCLAlertView/workflows/Building/badge.svg) 7 | [![Cocoapods](http://img.shields.io/cocoapods/v/SCLAlertView-Objective-C.svg)](http://cocoapods.org/?q=SCLAlertView-Objective-C) 8 | [![Pod License](http://img.shields.io/cocoapods/l/SCLAlertView-Objective-C.svg)](https://github.com/dogo/SCLAlertView/blob/master/LICENSE) 9 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 10 | 11 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot.png)_ 12 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot2.png) 13 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot3.png)_ 14 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot4.png) 15 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot5.png)_ 16 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot6.png) 17 | ![BackgroundImage](https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot7.png) 18 | 19 | ### Fluent style 20 | 21 | ```Objective-C 22 | 23 | SCLAlertViewBuilder *builder = [SCLAlertViewBuilder new] 24 | .addButtonWithActionBlock(@"Send", ^{ /*work here*/ }); 25 | SCLAlertViewShowBuilder *showBuilder = [SCLAlertViewShowBuilder new] 26 | .style(SCLAlertViewStyleWarning) 27 | .title(@"Title") 28 | .subTitle(@"Subtitle") 29 | .duration(0); 30 | [showBuilder showAlertView:builder.alertView onViewController:self.window.rootViewController]; 31 | // or even 32 | showBuilder.show(builder.alertView, self.window.rootViewController); 33 | ``` 34 | 35 | #### Complex 36 | ```Objective-C 37 | NSString *title = @"Title"; 38 | NSString *message = @"Message"; 39 | NSString *cancel = @"Cancel"; 40 | NSString *done = @"Done"; 41 | 42 | SCLALertViewTextFieldBuilder *textField = [SCLALertViewTextFieldBuilder new].title(@"Code"); 43 | SCLALertViewButtonBuilder *doneButton = [SCLALertViewButtonBuilder new].title(done) 44 | .validationBlock(^BOOL{ 45 | NSString *code = [textField.textField.text copy]; 46 | return [code isVisible]; 47 | }) 48 | .actionBlock(^{ 49 | NSString *code = [textField.textField.text copy]; 50 | [self confirmPhoneNumberWithCode:code]; 51 | }); 52 | 53 | SCLAlertViewBuilder *builder = [SCLAlertViewBuilder new] 54 | .showAnimationType(SCLAlertViewShowAnimationFadeIn) 55 | .hideAnimationType(SCLAlertViewHideAnimationFadeOut) 56 | .shouldDismissOnTapOutside(NO) 57 | .addTextFieldWithBuilder(textField) 58 | .addButtonWithBuilder(doneButton); 59 | 60 | SCLAlertViewShowBuilder *showBuilder = [SCLAlertViewShowBuilder new] 61 | .style(SCLAlertViewStyleCustom) 62 | .image([SCLAlertViewStyleKit imageOfInfo]) 63 | .color([UIColor blueColor]) 64 | .title(title) 65 | .subTitle(message) 66 | .closeButtonTitle(cancel) 67 | .duration(0.0f); 68 | 69 | [showBuilder showAlertView:builder.alertView onViewController:self]; 70 | ``` 71 | 72 | ### Easy to use 73 | ```Objective-C 74 | // Get started 75 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 76 | 77 | [alert showSuccess:self title:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f]; 78 | 79 | // Alternative alert types 80 | [alert showError:self title:@"Hello Error" subTitle:@"This is a more descriptive error text." closeButtonTitle:@"OK" duration:0.0f]; // Error 81 | [alert showNotice:self title:@"Hello Notice" subTitle:@"This is a more descriptive notice text." closeButtonTitle:@"Done" duration:0.0f]; // Notice 82 | [alert showWarning:self title:@"Hello Warning" subTitle:@"This is a more descriptive warning text." closeButtonTitle:@"Done" duration:0.0f]; // Warning 83 | [alert showInfo:self title:@"Hello Info" subTitle:@"This is a more descriptive info text." closeButtonTitle:@"Done" duration:0.0f]; // Info 84 | [alert showEdit:self title:@"Hello Edit" subTitle:@"This is a more descriptive info text with a edit textbox" closeButtonTitle:@"Done" duration:0.0f]; // Edit 85 | [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 86 | [alert showWaiting:self title:@"Waiting..." subTitle:@"Blah de blah de blah, blah. Blah de blah de" closeButtonTitle:nil duration:5.0f]; 87 | [alert showQuestion:self title:@"Question?" subTitle:kSubtitle closeButtonTitle:@"Dismiss" duration:0.0f]; 88 | 89 | 90 | // Using custom alert width 91 | SCLAlertView *alert = [[SCLAlertView alloc] initWithWindowWidth:300.0f]; 92 | ``` 93 | 94 | ### SCLAlertview in a new window. (No UIViewController) 95 | ```Objective-C 96 | 97 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow]; 98 | 99 | [alert showSuccess:@"Hello World" subTitle:@"This is a more descriptive text." closeButtonTitle:@"Done" duration:0.0f]; 100 | 101 | // Alternative alert types 102 | [alert showError:@"Hello Error" subTitle:@"This is a more descriptive error text." closeButtonTitle:@"OK" duration:0.0f]; // Error 103 | [alert showNotice:@"Hello Notice" subTitle:@"This is a more descriptive notice text." closeButtonTitle:@"Done" duration:0.0f]; // Notice 104 | [alert showWarning:@"Hello Warning" subTitle:@"This is a more descriptive warning text." closeButtonTitle:@"Done" duration:0.0f]; // Warning 105 | [alert showInfo:@"Hello Info" subTitle:@"This is a more descriptive info text." closeButtonTitle:@"Done" duration:0.0f]; // Info 106 | [alert showEdit:@"Hello Edit" subTitle:@"This is a more descriptive info text with a edit textbox" closeButtonTitle:@"Done" duration:0.0f]; // Edit 107 | [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 108 | [alert showWaiting:@"Waiting..." subTitle:@"Blah de blah de blah, blah. Blah de blah de" closeButtonTitle:nil duration:5.0f]; 109 | [alert showQuestion:@"Question?" subTitle:kSubtitle closeButtonTitle:@"Dismiss" duration:0.0f]; 110 | 111 | // Using custom alert width 112 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:300.0f]; 113 | ``` 114 | 115 | ### Add buttons 116 | ```Objective-C 117 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 118 | 119 | //Using Selector 120 | [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; 121 | 122 | //Using Block 123 | [alert addButton:@"Second Button" actionBlock:^(void) { 124 | NSLog(@"Second button tapped"); 125 | }]; 126 | 127 | //Using Blocks With Validation 128 | [alert addButton:@"Validate" validationBlock:^BOOL { 129 | BOOL passedValidation = .... 130 | return passedValidation; 131 | 132 | } actionBlock:^{ 133 | // handle successful validation here 134 | }]; 135 | 136 | [alert showSuccess:self title:@"Button View" subTitle:@"This alert view has buttons" closeButtonTitle:@"Done" duration:0.0f]; 137 | ``` 138 | 139 | ### Add button timer 140 | ```Objective-C 141 | //The index of the button to add the timer display to. 142 | [alert addTimerToButtonIndex:0 reverse:NO]; 143 | ``` 144 | 145 | Example: 146 | 147 | ```Objective-C 148 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 149 | [alert addTimerToButtonIndex:0 reverse:YES]; 150 | [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]; 151 | ``` 152 | 153 | 154 | ### Add Text Attributes 155 | ```Objective-C 156 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 157 | 158 | alert.attributedFormatBlock = ^NSAttributedString* (NSString *value) 159 | { 160 | NSMutableAttributedString *subTitle = [[NSMutableAttributedString alloc]initWithString:value]; 161 | 162 | NSRange redRange = [value rangeOfString:@"Attributed" options:NSCaseInsensitiveSearch]; 163 | [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; 164 | 165 | NSRange greenRange = [value rangeOfString:@"successfully" options:NSCaseInsensitiveSearch]; 166 | [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:greenRange]; 167 | 168 | NSRange underline = [value rangeOfString:@"completed" options:NSCaseInsensitiveSearch]; 169 | [subTitle addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)} range:underline]; 170 | 171 | return subTitle; 172 | }; 173 | 174 | [alert showSuccess:self title:@"Button View" subTitle:@"Attributed string operation successfully completed." closeButtonTitle:@"Done" duration:0.0f]; 175 | ``` 176 | 177 | ### Add a text field 178 | ```Objective-C 179 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 180 | 181 | UITextField *textField = [alert addTextField:@"Enter your name" setDefaultText:nil]; 182 | 183 | [alert addButton:@"Show Name" actionBlock:^(void) { 184 | NSLog(@"Text value: %@", textField.text); 185 | }]; 186 | 187 | [alert showEdit:self title:@"Edit View" subTitle:@"This alert view shows a text box" closeButtonTitle:@"Done" duration:0.0f]; 188 | ``` 189 | 190 | ### Indeterminate progress 191 | ```Objective-C 192 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 193 | 194 | [alert showWaiting:self title:@"Waiting..." subTitle:@"Blah de blah de blah, blah. Blah de blah de" closeButtonTitle:nil duration:5.0f]; 195 | ``` 196 | 197 | ### Add a switch button 198 | ```Objective-C 199 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 200 | 201 | SCLSwitchView *switchView = [alert addSwitchViewWithLabel:@"Don't show again".uppercaseString]; 202 | switchView.tintColor = [UIColor brownColor]; 203 | 204 | [alert addButton:@"Done" actionBlock:^(void) { 205 | NSLog(@"Show again? %@", switchView.isSelected ? @"-No": @"-Yes"); 206 | }]; 207 | 208 | [alert showCustom:self image:[UIImage imageNamed:@"switch"] color:[UIColor brownColor] title:kInfoTitle subTitle:kSubtitle closeButtonTitle:nil duration:0.0f]; 209 | ``` 210 | 211 | ### Add custom view 212 | ```Objective-C 213 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 214 | 215 | UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 215.0f, 80.0f)]; 216 | customView.backgroundColor = [UIColor redColor]; 217 | 218 | [alert addCustomView:customView]; 219 | 220 | [alert showNotice:self title:@"Title" subTitle:@"This alert view shows a custom view" closeButtonTitle:@"Done" duration:0.0f]; 221 | ``` 222 | 223 | ### SCLAlertView properties 224 | ```Objective-C 225 | //Dismiss on tap outside (Default is NO) 226 | alert.shouldDismissOnTapOutside = YES; 227 | 228 | //Hide animation type (Default is SCLAlertViewHideAnimationFadeOut) 229 | alert.hideAnimationType = SCLAlertViewHideAnimationSlideOutToBottom; 230 | 231 | //Show animation type (Default is SCLAlertViewShowAnimationSlideInFromTop) 232 | alert.showAnimationType = SCLAlertViewShowAnimationSlideInFromLeft; 233 | 234 | //Set background type (Default is SCLAlertViewBackgroundShadow) 235 | alert.backgroundType = SCLAlertViewBackgroundBlur; 236 | 237 | //Overwrite SCLAlertView (Buttons, top circle and borders) colors 238 | alert.customViewColor = [UIColor purpleColor]; 239 | 240 | //Set custom tint color for icon image. 241 | alert.iconTintColor = [UIColor purpleColor]; 242 | 243 | //Override top circle tint color with background color 244 | alert.tintTopCircle = NO; 245 | 246 | //Set custom corner radius for SCLAlertView 247 | alert.cornerRadius = 13.0f; 248 | 249 | //Overwrite SCLAlertView background color 250 | alert.backgroundViewColor = [UIColor cyanColor]; 251 | 252 | //Returns if the alert is visible or not. 253 | alert.isVisible; 254 | 255 | //Make the top circle icon larger 256 | alert.useLargerIcon = YES; 257 | 258 | //Using sound 259 | alert.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/right_answer.mp3", [[NSBundle mainBundle] resourcePath]]]; 260 | 261 | 262 | ``` 263 | 264 | ### Helpers 265 | ```Objective-C 266 | //Receiving information that SCLAlertView is dismissed 267 | [alert alertIsDismissed:^{ 268 | NSLog(@"SCLAlertView dismissed!"); 269 | }]; 270 | ``` 271 | 272 | #### Alert View Styles 273 | ```Objective-C 274 | typedef NS_ENUM(NSInteger, SCLAlertViewStyle) 275 | { 276 | SCLAlertViewStyleSuccess, 277 | SCLAlertViewStyleError, 278 | SCLAlertViewStyleNotice, 279 | SCLAlertViewStyleWarning, 280 | SCLAlertViewStyleInfo, 281 | SCLAlertViewStyleEdit, 282 | SCLAlertViewStyleWaiting, 283 | SCLAlertViewStyleQuestion, 284 | SCLAlertViewStyleCustom 285 | }; 286 | ``` 287 | #### Alert View hide animation styles 288 | ```Objective-C 289 | typedef NS_ENUM(NSInteger, SCLAlertViewHideAnimation) 290 | { 291 | SCLAlertViewHideAnimationFadeOut, 292 | SCLAlertViewHideAnimationSlideOutToBottom, 293 | SCLAlertViewHideAnimationSlideOutToTop, 294 | SCLAlertViewHideAnimationSlideOutToLeft, 295 | SCLAlertViewHideAnimationSlideOutToRight, 296 | SCLAlertViewHideAnimationSlideOutToCenter, 297 | SCLAlertViewHideAnimationSlideOutFromCenter, 298 | SCLAlertViewHideAnimationSimplyDisappear 299 | }; 300 | ``` 301 | #### Alert View show animation styles 302 | ```Objective-C 303 | typedef NS_ENUM(NSInteger, SCLAlertViewShowAnimation) 304 | { 305 | SCLAlertViewShowAnimationFadeIn, 306 | SCLAlertViewShowAnimationSlideInFromBottom, 307 | SCLAlertViewShowAnimationSlideInFromTop, 308 | SCLAlertViewShowAnimationSlideInFromLeft, 309 | SCLAlertViewShowAnimationSlideInFromRight, 310 | SCLAlertViewShowAnimationSlideInFromCenter, 311 | SCLAlertViewShowAnimationSlideInToCenter, 312 | SCLAlertViewShowAnimationSimplyAppear 313 | }; 314 | ``` 315 | 316 | #### Alert View background styles 317 | ```Objective-C 318 | typedef NS_ENUM(NSInteger, SCLAlertViewBackground) 319 | { 320 | SCLAlertViewBackgroundShadow, 321 | SCLAlertViewBackgroundBlur, 322 | SCLAlertViewBackgroundTransparent 323 | }; 324 | ``` 325 | 326 | ### Installation 327 | SCLAlertView-Objective-C is available through : 328 | 329 | ### [CocoaPods](https://cocoapods.org) 330 | 331 | To install add the following line to your Podfile: 332 | 333 | pod 'SCLAlertView-Objective-C' 334 | 335 | ### [Carthage](https://github.com/Carthage/Carthage) 336 | 337 | ``` 338 | github "dogo/SCLAlertView" 339 | ``` 340 | 341 | ### Collaboration 342 | I tried to build an easy to use API, while beeing flexible enough for multiple variations, but I'm sure there are ways of improving and adding more features, so feel free to collaborate with ideas, issues and/or pull requests. 343 | 344 | ### Incoming improvements 345 | - More animations 346 | - Performance tests 347 | - Remove some hardcode values 348 | 349 | ### Plugin integrations 350 | 351 | - [nativescript-fancyalert for NativeScript](https://github.com/NathanWalker/nativescript-fancyalert) 352 | - Use SCLAlertView with [NativeScript](https://www.nativescript.org/) 353 | 354 | ### Thanks to the original team 355 | - Design [@SherzodMx](https://twitter.com/SherzodMx) Sherzod Max 356 | - Development [@hackua](https://twitter.com/hackua) Viktor Radchenko 357 | - Improvements by [@bih](http://github.com/bih) Bilawal Hameed, [@rizjoj](http://github.com/rizjoj) Riz Joj 358 | 359 | https://github.com/vikmeup/SCLAlertView-Swift 360 | -------------------------------------------------------------------------------- /SCLAlertView-Objective-C.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = "SCLAlertView-Objective-C" 3 | spec.version = "1.3.0" 4 | spec.summary = "Beautiful animated Alert View. Written in Swift but ported to Objective-C" 5 | spec.homepage = "https://github.com/dogo/SCLAlertView" 6 | spec.screenshots = "https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot.png", "https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot2.png" 7 | 8 | spec.license = { :type => "MIT", :file => "LICENSE" } 9 | spec.author = { "Diogo Autilio" => "diautilio@gmail.com" } 10 | spec.social_media_url = "http://twitter.com/di_autilio" 11 | spec.platform = :ios 12 | spec.frameworks = "UIKit", "AudioToolbox", "Accelerate", "CoreGraphics" 13 | spec.ios.deployment_target = '9.0' 14 | spec.source = { :git => "https://github.com/dogo/SCLAlertView.git", :tag => spec.version.to_s } 15 | spec.source_files = "SCLAlertView/*" 16 | spec.requires_arc = true 17 | end 18 | -------------------------------------------------------------------------------- /SCLAlertView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SCLAlertView.xcodeproj/xcshareddata/xcschemes/SCLAlertView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /SCLAlertView.xcodeproj/xcshareddata/xcschemes/SCLAlertViewFramework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 52 | 53 | 59 | 60 | 66 | 67 | 68 | 69 | 71 | 72 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /SCLAlertView/SCLAlertView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertView.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #if defined(__has_feature) && __has_feature(modules) 10 | @import UIKit; 11 | #else 12 | #import 13 | #endif 14 | #import "SCLButton.h" 15 | #import "SCLTextView.h" 16 | #import "SCLSwitchView.h" 17 | 18 | typedef NSAttributedString* (^SCLAttributedFormatBlock)(NSString *value); 19 | typedef void (^SCLDismissBlock)(void); 20 | typedef void (^SCLDismissAnimationCompletionBlock)(void); 21 | typedef void (^SCLShowAnimationCompletionBlock)(void); 22 | typedef void (^SCLForceHideBlock)(void); 23 | 24 | @interface SCLAlertView : UIViewController 25 | 26 | /** Alert Styles 27 | * 28 | * Set SCLAlertView Style 29 | */ 30 | typedef NS_ENUM(NSInteger, SCLAlertViewStyle) 31 | { 32 | SCLAlertViewStyleSuccess, 33 | SCLAlertViewStyleError, 34 | SCLAlertViewStyleNotice, 35 | SCLAlertViewStyleWarning, 36 | SCLAlertViewStyleInfo, 37 | SCLAlertViewStyleEdit, 38 | SCLAlertViewStyleWaiting, 39 | SCLAlertViewStyleQuestion, 40 | SCLAlertViewStyleCustom 41 | }; 42 | 43 | /** Alert hide animation styles 44 | * 45 | * Set SCLAlertView hide animation type. 46 | */ 47 | typedef NS_ENUM(NSInteger, SCLAlertViewHideAnimation) 48 | { 49 | SCLAlertViewHideAnimationFadeOut, 50 | SCLAlertViewHideAnimationSlideOutToBottom, 51 | SCLAlertViewHideAnimationSlideOutToTop, 52 | SCLAlertViewHideAnimationSlideOutToLeft, 53 | SCLAlertViewHideAnimationSlideOutToRight, 54 | SCLAlertViewHideAnimationSlideOutToCenter, 55 | SCLAlertViewHideAnimationSlideOutFromCenter, 56 | SCLAlertViewHideAnimationSimplyDisappear 57 | }; 58 | 59 | /** Alert show animation styles 60 | * 61 | * Set SCLAlertView show animation type. 62 | */ 63 | typedef NS_ENUM(NSInteger, SCLAlertViewShowAnimation) 64 | { 65 | SCLAlertViewShowAnimationFadeIn, 66 | SCLAlertViewShowAnimationSlideInFromBottom, 67 | SCLAlertViewShowAnimationSlideInFromTop, 68 | SCLAlertViewShowAnimationSlideInFromLeft, 69 | SCLAlertViewShowAnimationSlideInFromRight, 70 | SCLAlertViewShowAnimationSlideInFromCenter, 71 | SCLAlertViewShowAnimationSlideInToCenter, 72 | SCLAlertViewShowAnimationSimplyAppear 73 | }; 74 | 75 | /** Alert background styles 76 | * 77 | * Set SCLAlertView background type. 78 | */ 79 | typedef NS_ENUM(NSInteger, SCLAlertViewBackground) 80 | { 81 | SCLAlertViewBackgroundShadow, 82 | SCLAlertViewBackgroundBlur, 83 | SCLAlertViewBackgroundTransparent 84 | }; 85 | 86 | /** Content view corner radius 87 | * 88 | * A float value that replaces the standard content viuew corner radius. 89 | */ 90 | @property CGFloat cornerRadius; 91 | 92 | /** Tint top circle 93 | * 94 | * A boolean value that determines whether to tint the SCLAlertView top circle. 95 | * (Default: YES) 96 | */ 97 | @property (assign, nonatomic) BOOL tintTopCircle; 98 | 99 | /** Use larger icon 100 | * 101 | * A boolean value that determines whether to make the SCLAlertView top circle icon larger. 102 | * (Default: NO) 103 | */ 104 | @property (assign, nonatomic) BOOL useLargerIcon; 105 | 106 | /** Title Label 107 | * 108 | * The text displayed as title. 109 | */ 110 | @property (strong, nonatomic) UILabel *labelTitle; 111 | 112 | /** Text view with the body message 113 | * 114 | * Holds the textview. 115 | */ 116 | @property (strong, nonatomic) UITextView *viewText; 117 | 118 | /** Activity Indicator 119 | * 120 | * Holds the activityIndicator. 121 | */ 122 | @property (strong, nonatomic) UIActivityIndicatorView *activityIndicatorView; 123 | 124 | /** Dismiss on tap outside 125 | * 126 | * A boolean value that determines whether to dismiss when tapping outside the SCLAlertView. 127 | * (Default: NO) 128 | */ 129 | @property (assign, nonatomic) BOOL shouldDismissOnTapOutside; 130 | 131 | /** Sound URL 132 | * 133 | * Holds the sound NSURL path. 134 | */ 135 | @property (strong, nonatomic) NSURL *soundURL; 136 | 137 | /** Set text attributed format block 138 | * 139 | * Holds the attributed string. 140 | */ 141 | @property (copy, nonatomic) SCLAttributedFormatBlock attributedFormatBlock; 142 | 143 | /** Set Complete button format block. 144 | * 145 | * Holds the button format block. 146 | * Support keys : backgroundColor, borderWidth, borderColor, textColor 147 | */ 148 | @property (copy, nonatomic) CompleteButtonFormatBlock completeButtonFormatBlock; 149 | 150 | /** Set button format block. 151 | * 152 | * Holds the button format block. 153 | * Support keys : backgroundColor, borderWidth, borderColor, textColor 154 | */ 155 | @property (copy, nonatomic) ButtonFormatBlock buttonFormatBlock; 156 | 157 | /** Set force hide block. 158 | * 159 | * When set force hideview method invocation. 160 | */ 161 | @property (copy, nonatomic) SCLForceHideBlock forceHideBlock; 162 | 163 | /** Hide animation type 164 | * 165 | * Holds the hide animation type. 166 | * (Default: FadeOut) 167 | */ 168 | @property (nonatomic) SCLAlertViewHideAnimation hideAnimationType; 169 | 170 | /** Show animation type 171 | * 172 | * Holds the show animation type. 173 | * (Default: SlideInFromTop) 174 | */ 175 | @property (nonatomic) SCLAlertViewShowAnimation showAnimationType; 176 | 177 | /** Set SCLAlertView background type. 178 | * 179 | * SCLAlertView background type. 180 | * (Default: Shadow) 181 | */ 182 | @property (nonatomic) SCLAlertViewBackground backgroundType; 183 | 184 | /** Set custom color to SCLAlertView. 185 | * 186 | * SCLAlertView custom color. 187 | * (Buttons, top circle and borders) 188 | */ 189 | @property (strong, nonatomic) UIColor *customViewColor; 190 | 191 | /** Set custom color to SCLAlertView background. 192 | * 193 | * SCLAlertView background custom color. 194 | */ 195 | @property (strong, nonatomic) UIColor *backgroundViewColor; 196 | 197 | /** Set custom tint color for icon image. 198 | * 199 | * SCLAlertView icon tint color 200 | */ 201 | @property (strong, nonatomic) UIColor *iconTintColor; 202 | 203 | /** Set custom circle icon height. 204 | * 205 | * Circle icon height 206 | */ 207 | @property (nonatomic) CGFloat circleIconHeight; 208 | 209 | /** Set SCLAlertView extension bounds. 210 | * 211 | * Set new bounds (EXTENSION ONLY) 212 | */ 213 | @property (nonatomic) CGRect extensionBounds; 214 | 215 | /** Set status bar hidden. 216 | * 217 | * Status bar hidden 218 | */ 219 | @property (nonatomic) BOOL statusBarHidden; 220 | 221 | /** Set status bar style. 222 | * 223 | * Status bar style 224 | */ 225 | @property (nonatomic) UIStatusBarStyle statusBarStyle; 226 | 227 | /** Set horizontal alignment for buttons 228 | * 229 | * Horizontal aligment instead of vertically if YES 230 | */ 231 | @property (nonatomic) BOOL horizontalButtons; 232 | 233 | /** Initialize SCLAlertView using specific width. 234 | * 235 | * Init instance 236 | */ 237 | - (instancetype)initWithWidth:(CGFloat)width; 238 | 239 | /** Initialize SCLAlertView using a new window. 240 | * 241 | * Init with new window 242 | */ 243 | - (instancetype)initWithNewWindow; 244 | 245 | /** Initialize SCLAlertView using a new window. 246 | * 247 | * Init with new window with custom width 248 | */ 249 | - (instancetype)initWithNewWindowWidth:(CGFloat)windowWidth; 250 | 251 | /** Warns that alerts is gone 252 | * 253 | * Warns that alerts is gone using block 254 | */ 255 | - (void)alertIsDismissed:(SCLDismissBlock)dismissBlock; 256 | 257 | /** Warns that alerts dismiss animation is completed 258 | * 259 | * Warns that alerts dismiss animation is completed 260 | */ 261 | - (void)alertDismissAnimationIsCompleted:(SCLDismissAnimationCompletionBlock)dismissAnimationCompletionBlock; 262 | 263 | /** Warns that alerts show animation is completed 264 | * 265 | * Warns that alerts show animation is completed 266 | */ 267 | - (void)alertShowAnimationIsCompleted:(SCLShowAnimationCompletionBlock)showAnimationCompletionBlock; 268 | 269 | /** Hide SCLAlertView 270 | * 271 | * Hide SCLAlertView using animation and removing from super view. 272 | */ 273 | 274 | - (void)hideView; 275 | 276 | /** SCLAlertView visibility 277 | * 278 | * Returns if the alert is visible or not. 279 | */ 280 | - (BOOL)isVisible; 281 | 282 | /** Remove Top Circle 283 | * 284 | * Remove top circle from SCLAlertView. 285 | */ 286 | - (void)removeTopCircle; 287 | 288 | /** Add a custom UIView 289 | * 290 | * @param customView UIView object to be added above the first SCLButton. 291 | */ 292 | - (UIView *)addCustomView:(UIView *)customView; 293 | 294 | /** Add Text Field 295 | * 296 | * @param title The text displayed on the textfield. 297 | */ 298 | - (SCLTextView *)addTextField:(NSString *)title setDefaultText:(NSString *)defaultText; 299 | 300 | /** Add a custom Text Field 301 | * 302 | * @param textField The custom textfield provided by the programmer. 303 | */ 304 | - (void)addCustomTextField:(UITextField *)textField; 305 | 306 | /** Add a switch view 307 | * 308 | * @param label The label displayed for the switch. 309 | */ 310 | - (SCLSwitchView *)addSwitchViewWithLabel:(NSString *)label; 311 | 312 | /** Add Timer Display 313 | * 314 | * @param buttonIndex The index of the button to add the timer display to. 315 | * @param reverse Convert timer to countdown. 316 | */ 317 | - (void)addTimerToButtonIndex:(NSInteger)buttonIndex reverse:(BOOL)reverse; 318 | 319 | /** Set Title font family and size 320 | * 321 | * @param titleFontFamily The family name used to displayed the title. 322 | * @param size Font size. 323 | */ 324 | - (void)setTitleFontFamily:(NSString *)titleFontFamily withSize:(CGFloat)size; 325 | 326 | /** Set Text field font family and size 327 | * 328 | * @param bodyTextFontFamily The family name used to displayed the text field. 329 | * @param size Font size. 330 | */ 331 | - (void)setBodyTextFontFamily:(NSString *)bodyTextFontFamily withSize:(CGFloat)size; 332 | 333 | /** Set Buttons font family and size 334 | * 335 | * @param buttonsFontFamily The family name used to displayed the buttons. 336 | * @param size Font size. 337 | */ 338 | - (void)setButtonsTextFontFamily:(NSString *)buttonsFontFamily withSize:(CGFloat)size; 339 | 340 | /** Add a Button with a title and a block to handle when the button is pressed. 341 | * 342 | * @param title The text displayed on the button. 343 | * @param action A block of code to be executed when the button is pressed. 344 | */ 345 | - (SCLButton *)addButton:(NSString *)title actionBlock:(SCLActionBlock)action; 346 | 347 | /** Add a Button with a title, a block to handle validation, and a block to handle when the button is pressed and validation succeeds. 348 | * 349 | * @param title The text displayed on the button. 350 | * @param validationBlock A block of code that will allow you to validate fields or do any other logic you may want to do to determine if the alert should be dismissed or not. Inside of this block, return a BOOL indicating whether or not the action block should be called and the alert dismissed. 351 | * @param action A block of code to be executed when the button is pressed and validation passes. 352 | */ 353 | - (SCLButton *)addButton:(NSString *)title validationBlock:(SCLValidationBlock)validationBlock actionBlock:(SCLActionBlock)action; 354 | 355 | /** Add a Button with a title, a target and a selector to handle when the button is pressed. 356 | * 357 | * @param title The text displayed on the button. 358 | * @param target Add target for particular event. 359 | * @param selector A method to be executed when the button is pressed. 360 | */ 361 | - (SCLButton *)addButton:(NSString *)title target:(id)target selector:(SEL)selector; 362 | 363 | /** Show Success SCLAlertView 364 | * 365 | * @param vc The view controller the alert view will be displayed in. 366 | * @param title The text displayed on the button. 367 | * @param subTitle The subtitle text of the alert view. 368 | * @param closeButtonTitle The text for the close button. 369 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 370 | */ 371 | - (void)showSuccess:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 372 | - (void)showSuccess:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 373 | 374 | /** Show Error SCLAlertView 375 | * 376 | * @param vc The view controller the alert view will be displayed in. 377 | * @param title The text displayed on the button. 378 | * @param subTitle The subtitle text of the alert view. 379 | * @param closeButtonTitle The text for the close button. 380 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 381 | */ 382 | - (void)showError:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 383 | - (void)showError:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 384 | 385 | /** Show Notice SCLAlertView 386 | * 387 | * @param vc The view controller the alert view will be displayed in. 388 | * @param title The text displayed on the button. 389 | * @param subTitle The subtitle text of the alert view. 390 | * @param closeButtonTitle The text for the close button. 391 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 392 | */ 393 | - (void)showNotice:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 394 | - (void)showNotice:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 395 | 396 | /** Show Warning SCLAlertView 397 | * 398 | * @param vc The view controller the alert view will be displayed in. 399 | * @param title The text displayed on the button. 400 | * @param subTitle The subtitle text of the alert view. 401 | * @param closeButtonTitle The text for the close button. 402 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 403 | */ 404 | - (void)showWarning:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 405 | - (void)showWarning:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 406 | 407 | /** Show Info SCLAlertView 408 | * 409 | * @param vc The view controller the alert view will be displayed in. 410 | * @param title The text displayed on the button. 411 | * @param subTitle The subtitle text of the alert view. 412 | * @param closeButtonTitle The text for the close button. 413 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 414 | */ 415 | - (void)showInfo:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 416 | - (void)showInfo:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 417 | 418 | /** Show Edit SCLAlertView 419 | * 420 | * @param vc The view controller the alert view will be displayed in. 421 | * @param title The text displayed on the button. 422 | * @param subTitle The subtitle text of the alert view. 423 | * @param closeButtonTitle The text for the close button. 424 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 425 | */ 426 | - (void)showEdit:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 427 | - (void)showEdit:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 428 | 429 | /** Show Title SCLAlertView using a predefined type 430 | * 431 | * @param vc The view controller the alert view will be displayed in. 432 | * @param title The text displayed on the button. 433 | * @param subTitle The subtitle text of the alert view. 434 | * @param style One of predefined SCLAlertView styles. 435 | * @param closeButtonTitle The text for the close button. 436 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 437 | */ 438 | - (void)showTitle:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle style:(SCLAlertViewStyle)style closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 439 | - (void)showTitle:(NSString *)title subTitle:(NSString *)subTitle style:(SCLAlertViewStyle)style closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 440 | 441 | /** Shows a custom SCLAlertView without using a predefined type, allowing for a custom image and color to be specified. 442 | * 443 | * @param vc The view controller the alert view will be displayed in. 444 | * @param image A UIImage object to be used as the icon for the alert view. 445 | * @param color A UIColor object to be used to tint the background of the icon circle and the buttons. 446 | * @param title The title text of the alert view. 447 | * @param subTitle The subtitle text of the alert view. 448 | * @param closeButtonTitle The text for the close button. 449 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 450 | */ 451 | - (void)showCustom:(UIViewController *)vc image:(UIImage *)image color:(UIColor *)color title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 452 | - (void)showCustom:(UIImage *)image color:(UIColor *)color title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 453 | 454 | /** Show Waiting SCLAlertView with UIActityIndicator. 455 | * 456 | * @param vc The view controller the alert view will be displayed in. 457 | * @param title The text displayed on the button. 458 | * @param subTitle The subtitle text of the alert view. 459 | * @param closeButtonTitle The text for the close button. 460 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 461 | */ 462 | - (void)showWaiting:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 463 | - (void)showWaiting:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 464 | 465 | /** Show Question SCLAlertView 466 | * 467 | * @param vc The view controller the alert view will be displayed in. 468 | * @param title The text displayed on the button. 469 | * @param subTitle The subtitle text of the alert view. 470 | * @param closeButtonTitle The text for the close button. 471 | * @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0. 472 | */ 473 | - (void)showQuestion:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 474 | - (void)showQuestion:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration; 475 | 476 | @end 477 | 478 | @protocol SCLItemsBuilder__Protocol__Fluent 479 | - (void)setupFluent; 480 | @end 481 | 482 | @interface SCLAlertViewBuilder__WithFluent: NSObject @end 483 | 484 | @interface SCLAlertViewShowBuilder : SCLAlertViewBuilder__WithFluent 485 | 486 | @property(weak, nonatomic, readonly) UIViewController *parameterViewController; 487 | @property(copy, nonatomic, readonly) UIImage *parameterImage; 488 | @property(copy, nonatomic, readonly) UIColor *parameterColor; 489 | @property(copy, nonatomic, readonly) NSString *parameterTitle; 490 | @property(copy, nonatomic, readonly) NSString *parameterSubTitle; 491 | @property(copy, nonatomic, readonly) NSString *parameterCompleteText; 492 | @property(copy, nonatomic, readonly) NSString *parameterCloseButtonTitle; 493 | @property(assign, nonatomic, readonly) SCLAlertViewStyle parameterStyle; 494 | @property(assign, nonatomic, readonly) NSTimeInterval parameterDuration; 495 | 496 | #pragma mark - Setters 497 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^viewController)(UIViewController *viewController); 498 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^image)(UIImage *image); 499 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^color)(UIColor *color); 500 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^title)(NSString *title); 501 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^subTitle)(NSString *subTitle); 502 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^completeText)(NSString *completeText); 503 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^style)(SCLAlertViewStyle style); 504 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^closeButtonTitle)(NSString *closeButtonTitle); 505 | @property(copy, nonatomic, readonly) SCLAlertViewShowBuilder *(^duration)(NSTimeInterval duration); 506 | 507 | - (void)showAlertView:(SCLAlertView *)alertView; 508 | - (void)showAlertView:(SCLAlertView *)alertView onViewController:(UIViewController *)controller; 509 | @property(copy, nonatomic, readonly) void (^show)(SCLAlertView *view, UIViewController *controller); 510 | @end 511 | 512 | @interface SCLALertViewTextFieldBuilder : SCLAlertViewBuilder__WithFluent 513 | 514 | #pragma mark - Available later after adding 515 | @property(weak, nonatomic, readonly) SCLTextView *textField; 516 | 517 | #pragma mark - Setters 518 | @property(copy, nonatomic, readonly) SCLALertViewTextFieldBuilder *(^title) (NSString *title); 519 | 520 | @end 521 | 522 | @interface SCLALertViewButtonBuilder : SCLAlertViewBuilder__WithFluent 523 | 524 | #pragma mark - Available later after adding 525 | @property(weak, nonatomic, readonly) SCLButton *button; 526 | 527 | #pragma mark - Setters 528 | @property(copy, nonatomic, readonly) SCLALertViewButtonBuilder *(^title) (NSString *title); 529 | @property(copy, nonatomic, readonly) SCLALertViewButtonBuilder *(^target) (id target); 530 | @property(copy, nonatomic, readonly) SCLALertViewButtonBuilder *(^selector) (SEL selector); 531 | @property(copy, nonatomic, readonly) SCLALertViewButtonBuilder *(^actionBlock) (void(^actionBlock)(void)); 532 | @property(copy, nonatomic, readonly) SCLALertViewButtonBuilder *(^validationBlock) (BOOL(^validationBlock)(void)); 533 | 534 | @end 535 | 536 | @interface SCLAlertViewBuilder : SCLAlertViewBuilder__WithFluent 537 | 538 | #pragma mark - Parameters 539 | @property (strong, nonatomic, readonly) SCLAlertView *alertView; 540 | 541 | #pragma mark - Init 542 | - (instancetype)init; 543 | - (instancetype)initWithNewWindow; 544 | - (instancetype)initWithNewWindowWidth:(CGFloat)width; 545 | 546 | #pragma mark - Properties 547 | @property(copy, nonatomic) SCLAlertViewBuilder *(^cornerRadius) (CGFloat cornerRadius); 548 | @property(copy, nonatomic) SCLAlertViewBuilder *(^tintTopCircle) (BOOL tintTopCircle); 549 | @property(copy, nonatomic) SCLAlertViewBuilder *(^useLargerIcon) (BOOL useLargerIcon); 550 | @property(copy, nonatomic) SCLAlertViewBuilder *(^labelTitle) (UILabel *labelTitle); 551 | @property(copy, nonatomic) SCLAlertViewBuilder *(^viewText) (UITextView *viewText); 552 | @property(copy, nonatomic) SCLAlertViewBuilder *(^activityIndicatorView) (UIActivityIndicatorView *activityIndicatorView); 553 | @property(copy, nonatomic) SCLAlertViewBuilder *(^shouldDismissOnTapOutside) (BOOL shouldDismissOnTapOutside); 554 | @property(copy, nonatomic) SCLAlertViewBuilder *(^soundURL) (NSURL *soundURL); 555 | @property(copy, nonatomic) SCLAlertViewBuilder *(^attributedFormatBlock) (SCLAttributedFormatBlock attributedFormatBlock); 556 | @property(copy, nonatomic) SCLAlertViewBuilder *(^completeButtonFormatBlock) (CompleteButtonFormatBlock completeButtonFormatBlock); 557 | @property(copy, nonatomic) SCLAlertViewBuilder *(^buttonFormatBlock) (ButtonFormatBlock buttonFormatBlock); 558 | @property(copy, nonatomic) SCLAlertViewBuilder *(^forceHideBlock) (SCLForceHideBlock forceHideBlock); 559 | @property(copy, nonatomic) SCLAlertViewBuilder *(^hideAnimationType) (SCLAlertViewHideAnimation hideAnimationType); 560 | @property(copy, nonatomic) SCLAlertViewBuilder *(^showAnimationType) (SCLAlertViewShowAnimation showAnimationType); 561 | @property(copy, nonatomic) SCLAlertViewBuilder *(^backgroundType) (SCLAlertViewBackground backgroundType); 562 | @property(copy, nonatomic) SCLAlertViewBuilder *(^customViewColor) (UIColor *customViewColor); 563 | @property(copy, nonatomic) SCLAlertViewBuilder *(^backgroundViewColor) (UIColor *backgroundViewColor); 564 | @property(copy, nonatomic) SCLAlertViewBuilder *(^iconTintColor) (UIColor *iconTintColor); 565 | @property(copy, nonatomic) SCLAlertViewBuilder *(^circleIconHeight) (CGFloat circleIconHeight); 566 | @property(copy, nonatomic) SCLAlertViewBuilder *(^extensionBounds) (CGRect extensionBounds); 567 | @property(copy, nonatomic) SCLAlertViewBuilder *(^statusBarHidden) (BOOL statusBarHidden); 568 | @property(copy, nonatomic) SCLAlertViewBuilder *(^statusBarStyle) (UIStatusBarStyle statusBarStyle); 569 | 570 | #pragma mark - Custom Setters 571 | @property(copy, nonatomic) SCLAlertViewBuilder *(^alertIsDismissed) (SCLDismissBlock dismissBlock); 572 | @property(copy, nonatomic) SCLAlertViewBuilder *(^alertDismissAnimationIsCompleted) (SCLDismissAnimationCompletionBlock dismissAnimationCompletionBlock); 573 | @property(copy, nonatomic) SCLAlertViewBuilder *(^alertShowAnimationIsCompleted) (SCLShowAnimationCompletionBlock showAnimationCompletionBlock); 574 | @property(copy, nonatomic) SCLAlertViewBuilder *(^removeTopCircle)(void); 575 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addCustomView)(UIView *view); 576 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addTextField)(NSString *title, NSString *defaultText); 577 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addCustomTextField)(UITextField *textField); 578 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addSwitchViewWithLabelTitle)(NSString *title); 579 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addTimerToButtonIndex)(NSInteger buttonIndex, BOOL reverse); 580 | @property(copy, nonatomic) SCLAlertViewBuilder *(^setTitleFontFamily)(NSString *titleFontFamily, CGFloat size); 581 | @property(copy, nonatomic) SCLAlertViewBuilder *(^setBodyTextFontFamily)(NSString *bodyTextFontFamily, CGFloat size); 582 | @property(copy, nonatomic) SCLAlertViewBuilder *(^setButtonsTextFontFamily)(NSString *buttonsFontFamily, CGFloat size); 583 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addButtonWithActionBlock)(NSString *title, SCLActionBlock action); 584 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addButtonWithValidationBlock)(NSString *title, SCLValidationBlock validationBlock, SCLActionBlock action); 585 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addButtonWithTarget)(NSString *title, id target, SEL selector); 586 | 587 | #pragma mark - Builders 588 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addButtonWithBuilder)(SCLALertViewButtonBuilder *builder); 589 | @property(copy, nonatomic) SCLAlertViewBuilder *(^addTextFieldWithBuilder)(SCLALertViewTextFieldBuilder *builder); 590 | 591 | @end 592 | -------------------------------------------------------------------------------- /SCLAlertView/SCLAlertViewResponder.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertViewResponder.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #if defined(__has_feature) && __has_feature(modules) 10 | @import Foundation; 11 | #else 12 | #import 13 | #endif 14 | #import "SCLAlertView.h" 15 | 16 | @interface SCLAlertViewResponder : NSObject 17 | 18 | /** TODO 19 | * 20 | * TODO 21 | */ 22 | - (instancetype)init:(SCLAlertView *)alertview; 23 | 24 | /** TODO 25 | * 26 | * TODO 27 | */ 28 | - (void)close; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /SCLAlertView/SCLAlertViewResponder.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertViewResponder.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "SCLAlertViewResponder.h" 10 | 11 | @interface SCLAlertViewResponder () 12 | 13 | @property SCLAlertView *alertview; 14 | 15 | @end 16 | 17 | @implementation SCLAlertViewResponder 18 | 19 | // 20 | //// Allow alerts to be closed/renamed in a chainable manner 21 | //// Example: SCLAlertView().showSuccess(self, title: "Test", subTitle: "Value").close() 22 | 23 | // Initialisation and Title/Subtitle/Close functions 24 | - (instancetype)init:(SCLAlertView *)alertview 25 | { 26 | self.alertview = alertview; 27 | return self; 28 | } 29 | 30 | - (void)setTitletitle:(NSString *)title 31 | { 32 | self.alertview.labelTitle.text = title; 33 | } 34 | 35 | - (void)setSubTitle:(NSString *)subTitle 36 | { 37 | self.alertview.viewText.text = subTitle; 38 | } 39 | 40 | - (void)close 41 | { 42 | [self.alertview hideView]; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SCLAlertView/SCLAlertViewStyleKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertViewStyleKit.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #if defined(__has_feature) && __has_feature(modules) 10 | @import Foundation; 11 | @import UIKit; 12 | #else 13 | #import 14 | #import 15 | #endif 16 | #import "SCLButton.h" 17 | 18 | @interface SCLAlertViewStyleKit : NSObject 19 | 20 | // Images 21 | /** TODO 22 | * 23 | * TODO 24 | */ 25 | + (UIImage *)imageOfCheckmark; 26 | 27 | /** TODO 28 | * 29 | * TODO 30 | */ 31 | + (UIImage *)imageOfCross; 32 | 33 | /** TODO 34 | * 35 | * TODO 36 | */ 37 | + (UIImage *)imageOfNotice; 38 | 39 | /** TODO 40 | * 41 | * TODO 42 | */ 43 | + (UIImage *)imageOfWarning; 44 | 45 | /** TODO 46 | * 47 | * TODO 48 | */ 49 | + (UIImage *)imageOfInfo; 50 | 51 | /** TODO 52 | * 53 | * TODO 54 | */ 55 | + (UIImage *)imageOfEdit; 56 | 57 | /** TODO 58 | * 59 | * TODO 60 | */ 61 | + (UIImage *)imageOfQuestion; 62 | 63 | /** TODO 64 | * 65 | * TODO 66 | */ 67 | + (void)drawCheckmark; 68 | 69 | /** TODO 70 | * 71 | * TODO 72 | */ 73 | + (void)drawCross; 74 | 75 | /** TODO 76 | * 77 | * TODO 78 | */ 79 | + (void)drawNotice; 80 | 81 | /** TODO 82 | * 83 | * TODO 84 | */ 85 | + (void)drawWarning; 86 | 87 | /** TODO 88 | * 89 | * TODO 90 | */ 91 | + (void)drawInfo; 92 | 93 | /** TODO 94 | * 95 | * TODO 96 | */ 97 | + (void)drawEdit; 98 | 99 | /** TODO 100 | * 101 | * TODO 102 | */ 103 | + (void)drawQuestion; 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /SCLAlertView/SCLAlertViewStyleKit.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertViewStyleKit.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "SCLAlertViewStyleKit.h" 10 | 11 | // ------------------------------------ 12 | // Icon drawing 13 | // Code generated by PaintCode 14 | // ------------------------------------ 15 | @implementation SCLAlertViewStyleKit 16 | 17 | #pragma mark - Cache 18 | 19 | static UIImage *imageOfCheckmark = nil; 20 | static UIImage *imageOfCross = nil; 21 | static UIImage *imageOfNotice = nil; 22 | static UIImage *imageOfWarning = nil; 23 | static UIImage *imageOfInfo = nil; 24 | static UIImage *imageOfEdit = nil; 25 | static UIImage *imageOfQuestion = nil; 26 | 27 | #pragma mark - Initialization 28 | 29 | + (void)initialize 30 | { 31 | // Do something 32 | } 33 | 34 | #pragma mark - Drawing Methods 35 | 36 | + (void)drawCheckmark 37 | { 38 | // Checkmark Shape Drawing 39 | UIBezierPath *checkmarkShapePath = [[UIBezierPath alloc] init]; 40 | [checkmarkShapePath moveToPoint:CGPointMake(73.25, 14.05)]; 41 | [checkmarkShapePath addCurveToPoint:CGPointMake(64.51, 13.86) controlPoint1: CGPointMake(70.98, 11.44) controlPoint2: CGPointMake(66.78, 11.26)]; 42 | [checkmarkShapePath addLineToPoint:CGPointMake(27.46, 52)]; 43 | [checkmarkShapePath addLineToPoint:CGPointMake(15.75, 39.54)]; 44 | [checkmarkShapePath addCurveToPoint:CGPointMake(6.84, 39.54) controlPoint1: CGPointMake(13.48, 36.93) controlPoint2: CGPointMake(9.28, 36.93)]; 45 | [checkmarkShapePath addCurveToPoint:CGPointMake(6.84, 49.02) controlPoint1: CGPointMake(4.39, 42.14) controlPoint2: CGPointMake(4.39, 46.42)]; 46 | [checkmarkShapePath addLineToPoint:CGPointMake(22.91, 66.14)]; 47 | [checkmarkShapePath addCurveToPoint:CGPointMake(27.28, 68) controlPoint1: CGPointMake(24.14, 67.44) controlPoint2: CGPointMake(25.71, 68)]; 48 | [checkmarkShapePath addCurveToPoint:CGPointMake(31.65, 66.14) controlPoint1: CGPointMake(28.86, 68) controlPoint2: CGPointMake(30.43, 67.26)]; 49 | [checkmarkShapePath addLineToPoint:CGPointMake(73.08, 23.35)]; 50 | [checkmarkShapePath addCurveToPoint:CGPointMake(73.25, 14.05) controlPoint1: CGPointMake(75.52, 20.75) controlPoint2: CGPointMake(75.7, 16.65)]; 51 | [checkmarkShapePath closePath]; 52 | checkmarkShapePath.miterLimit = 4; 53 | 54 | [[UIColor whiteColor] setFill]; 55 | [checkmarkShapePath fill]; 56 | } 57 | 58 | + (void)drawCross 59 | { 60 | // Cross Shape Drawing 61 | UIBezierPath *crossShapePath = [[UIBezierPath alloc] init]; 62 | [crossShapePath moveToPoint:CGPointMake(10, 70)]; 63 | [crossShapePath addLineToPoint:CGPointMake(70, 10)]; 64 | [crossShapePath moveToPoint:CGPointMake(10, 10)]; 65 | [crossShapePath addLineToPoint:CGPointMake(70, 70)]; 66 | 67 | crossShapePath.lineCapStyle = kCGLineCapRound; 68 | crossShapePath.lineJoinStyle = kCGLineJoinRound; 69 | 70 | [[UIColor whiteColor] setStroke]; 71 | crossShapePath.lineWidth = 14; 72 | [crossShapePath stroke]; 73 | } 74 | 75 | + (void)drawNotice 76 | { 77 | // Notice Shape Drawing 78 | UIBezierPath *noticeShapePath = [[UIBezierPath alloc] init]; 79 | [noticeShapePath moveToPoint:CGPointMake(72, 48.54)]; 80 | [noticeShapePath addLineToPoint:CGPointMake(72, 39.9)]; 81 | [noticeShapePath addCurveToPoint:CGPointMake(66.38, 34.01) controlPoint1: CGPointMake(72, 36.76) controlPoint2: CGPointMake(69.48, 34.01)]; 82 | [noticeShapePath addCurveToPoint:CGPointMake(61.53, 35.97) controlPoint1: CGPointMake(64.82, 34.01) controlPoint2: CGPointMake(62.69, 34.8)]; 83 | [noticeShapePath addCurveToPoint:CGPointMake(60.36, 35.78) controlPoint1: CGPointMake(61.33, 35.97) controlPoint2: CGPointMake(62.3, 35.78)]; 84 | [noticeShapePath addLineToPoint:CGPointMake(60.36, 33.22)]; 85 | [noticeShapePath addCurveToPoint:CGPointMake(54.16, 26.16) controlPoint1: CGPointMake(60.36, 29.3) controlPoint2: CGPointMake(57.65, 26.16)]; 86 | [noticeShapePath addCurveToPoint:CGPointMake(48.73, 29.89) controlPoint1: CGPointMake(51.64, 26.16) controlPoint2: CGPointMake(50.67, 27.73)]; 87 | [noticeShapePath addLineToPoint:CGPointMake(48.73, 28.71)]; 88 | [noticeShapePath addCurveToPoint:CGPointMake(43.49, 21.64) controlPoint1: CGPointMake(48.73, 24.78) controlPoint2: CGPointMake(46.98, 21.64)]; 89 | [noticeShapePath addCurveToPoint:CGPointMake(39.03, 25.37) controlPoint1: CGPointMake(40.97, 21.64) controlPoint2: CGPointMake(39.03, 23.01)]; 90 | [noticeShapePath addLineToPoint:CGPointMake(39.03, 9.07)]; 91 | [noticeShapePath addCurveToPoint:CGPointMake(32.24, 2) controlPoint1: CGPointMake(39.03, 5.14) controlPoint2: CGPointMake(35.73, 2)]; 92 | [noticeShapePath addCurveToPoint:CGPointMake(25.45, 9.07) controlPoint1: CGPointMake(28.56, 2) controlPoint2: CGPointMake(25.45, 5.14)]; 93 | [noticeShapePath addLineToPoint:CGPointMake(25.45, 41.47)]; 94 | [noticeShapePath addCurveToPoint:CGPointMake(24.29, 43.44) controlPoint1: CGPointMake(25.45, 42.45) controlPoint2: CGPointMake(24.68, 43.04)]; 95 | [noticeShapePath addCurveToPoint:CGPointMake(9.55, 43.04) controlPoint1: CGPointMake(16.73, 40.88) controlPoint2: CGPointMake(11.88, 40.69)]; 96 | [noticeShapePath addCurveToPoint:CGPointMake(8, 46.58) controlPoint1: CGPointMake(8.58, 43.83) controlPoint2: CGPointMake(8, 45.2)]; 97 | [noticeShapePath addCurveToPoint:CGPointMake(14.4, 55.81) controlPoint1: CGPointMake(8.19, 50.31) controlPoint2: CGPointMake(12.07, 53.84)]; 98 | [noticeShapePath addLineToPoint:CGPointMake(27.2, 69.56)]; 99 | [noticeShapePath addCurveToPoint:CGPointMake(42.91, 77.8) controlPoint1: CGPointMake(30.5, 74.47) controlPoint2: CGPointMake(35.73, 77.21)]; 100 | [noticeShapePath addCurveToPoint:CGPointMake(43.88, 77.8) controlPoint1: CGPointMake(43.3, 77.8) controlPoint2: CGPointMake(43.68, 77.8)]; 101 | [noticeShapePath addCurveToPoint:CGPointMake(47.18, 78) controlPoint1: CGPointMake(45.04, 77.8) controlPoint2: CGPointMake(46.01, 78)]; 102 | [noticeShapePath addLineToPoint:CGPointMake(48.34, 78)]; 103 | [noticeShapePath addLineToPoint:CGPointMake(48.34, 78)]; 104 | [noticeShapePath addCurveToPoint:CGPointMake(71.61, 52.08) controlPoint1: CGPointMake(56.48, 78) controlPoint2: CGPointMake(69.87, 75.05)]; 105 | [noticeShapePath addCurveToPoint:CGPointMake(72, 48.54) controlPoint1: CGPointMake(71.81, 51.29) controlPoint2: CGPointMake(72, 49.72)]; 106 | [noticeShapePath closePath]; 107 | noticeShapePath.miterLimit = 4; 108 | 109 | [[UIColor whiteColor] setFill]; 110 | [noticeShapePath fill]; 111 | } 112 | 113 | + (void)drawWarning 114 | { 115 | // Color Declarations 116 | UIColor *greyColor = [UIColor colorWithRed:0.236 green:0.236 blue:0.236 alpha:1.000]; 117 | 118 | // Warning Group 119 | // Warning Circle Drawing 120 | UIBezierPath *warningCirclePath = [[UIBezierPath alloc] init]; 121 | [warningCirclePath moveToPoint:CGPointMake(40.94, 63.39)]; 122 | [warningCirclePath addCurveToPoint:CGPointMake(36.03, 65.55) controlPoint1: CGPointMake(39.06, 63.39) controlPoint2: CGPointMake(37.36, 64.18)]; 123 | [warningCirclePath addCurveToPoint:CGPointMake(34.14, 70.45) controlPoint1: CGPointMake(34.9, 66.92) controlPoint2: CGPointMake(34.14, 68.49)]; 124 | [warningCirclePath addCurveToPoint:CGPointMake(36.22, 75.54) controlPoint1: CGPointMake(34.14, 72.41) controlPoint2: CGPointMake(34.9, 74.17)]; 125 | [warningCirclePath addCurveToPoint:CGPointMake(40.94, 77.5) controlPoint1: CGPointMake(37.54, 76.91) controlPoint2: CGPointMake(39.06, 77.5)]; 126 | [warningCirclePath addCurveToPoint:CGPointMake(45.86, 75.35) controlPoint1: CGPointMake(42.83, 77.5) controlPoint2: CGPointMake(44.53, 76.72)]; 127 | [warningCirclePath addCurveToPoint:CGPointMake(47.93, 70.45) controlPoint1: CGPointMake(47.18, 74.17) controlPoint2: CGPointMake(47.93, 72.41)]; 128 | [warningCirclePath addCurveToPoint:CGPointMake(45.86, 65.35) controlPoint1: CGPointMake(47.93, 68.49) controlPoint2: CGPointMake(47.18, 66.72)]; 129 | [warningCirclePath addCurveToPoint:CGPointMake(40.94, 63.39) controlPoint1: CGPointMake(44.53, 64.18) controlPoint2: CGPointMake(42.83, 63.39)]; 130 | [warningCirclePath closePath]; 131 | warningCirclePath.miterLimit = 4; 132 | 133 | [greyColor setFill]; 134 | [warningCirclePath fill]; 135 | 136 | 137 | //// Warning Shape Drawing 138 | UIBezierPath *warningShapePath = [[UIBezierPath alloc] init]; 139 | [warningShapePath moveToPoint:CGPointMake(46.23, 4.26)]; 140 | [warningShapePath addCurveToPoint:CGPointMake(40.94, 2.5) controlPoint1: CGPointMake(44.91, 3.09) controlPoint2: CGPointMake(43.02, 2.5)]; 141 | [warningShapePath addCurveToPoint:CGPointMake(34.71, 4.26) controlPoint1: CGPointMake(38.68, 2.5) controlPoint2: CGPointMake(36.03, 3.09)]; 142 | [warningShapePath addCurveToPoint:CGPointMake(31.5, 8.77) controlPoint1: CGPointMake(33.01, 5.44) controlPoint2: CGPointMake(31.5, 7.01)]; 143 | [warningShapePath addLineToPoint:CGPointMake(31.5, 19.36)]; 144 | [warningShapePath addLineToPoint:CGPointMake(34.71, 54.44)]; 145 | [warningShapePath addCurveToPoint:CGPointMake(40.38, 58.16) controlPoint1: CGPointMake(34.9, 56.2) controlPoint2: CGPointMake(36.41, 58.16)]; 146 | [warningShapePath addCurveToPoint:CGPointMake(45.67, 54.44) controlPoint1: CGPointMake(44.34, 58.16) controlPoint2: CGPointMake(45.67, 56.01)]; 147 | [warningShapePath addLineToPoint:CGPointMake(48.5, 19.36)]; 148 | [warningShapePath addLineToPoint:CGPointMake(48.5, 8.77)]; 149 | [warningShapePath addCurveToPoint:CGPointMake(46.23, 4.26) controlPoint1: CGPointMake(48.5, 7.01) controlPoint2: CGPointMake(47.74, 5.44)]; 150 | [warningShapePath closePath]; 151 | warningShapePath.miterLimit = 4; 152 | 153 | [greyColor setFill]; 154 | [warningShapePath fill]; 155 | } 156 | 157 | + (void)drawInfo 158 | { 159 | // Color Declarations 160 | UIColor *color0 = [UIColor colorWithRed:1.000 green:1.000 blue:1.000 alpha:1.000]; 161 | 162 | // Info Shape Drawing 163 | UIBezierPath *infoShapePath = [[UIBezierPath alloc] init]; 164 | [infoShapePath moveToPoint:CGPointMake(45.66, 15.96)]; 165 | [infoShapePath addCurveToPoint:CGPointMake(45.66, 5.22) controlPoint1: CGPointMake(48.78, 12.99) controlPoint2: CGPointMake(48.78, 8.19)]; 166 | [infoShapePath addCurveToPoint:CGPointMake(34.34, 5.22) controlPoint1: CGPointMake(42.53, 2.26) controlPoint2: CGPointMake(37.47, 2.26)]; 167 | [infoShapePath addCurveToPoint:CGPointMake(34.34, 15.96) controlPoint1: CGPointMake(31.22, 8.19) controlPoint2: CGPointMake(31.22, 12.99)]; 168 | [infoShapePath addCurveToPoint:CGPointMake(45.66, 15.96) controlPoint1: CGPointMake(37.47, 18.92) controlPoint2: CGPointMake(42.53, 18.92)]; 169 | [infoShapePath closePath]; 170 | 171 | [infoShapePath moveToPoint:CGPointMake(48, 69.41)]; 172 | [infoShapePath addCurveToPoint:CGPointMake(40, 77) controlPoint1: CGPointMake(48, 73.58) controlPoint2: CGPointMake(44.4, 77)]; 173 | [infoShapePath addLineToPoint:CGPointMake(40, 77)]; 174 | [infoShapePath addCurveToPoint:CGPointMake(32, 69.41) controlPoint1: CGPointMake(35.6, 77) controlPoint2: CGPointMake(32, 73.58)]; 175 | [infoShapePath addLineToPoint:CGPointMake(32, 35.26)]; 176 | [infoShapePath addCurveToPoint:CGPointMake(40, 27.67) controlPoint1: CGPointMake(32, 31.08) controlPoint2: CGPointMake(35.6, 27.67)]; 177 | [infoShapePath addLineToPoint:CGPointMake(40, 27.67)]; 178 | [infoShapePath addCurveToPoint:CGPointMake(48, 35.26) controlPoint1: CGPointMake(44.4, 27.67) controlPoint2: CGPointMake(48, 31.08)]; 179 | [infoShapePath addLineToPoint:CGPointMake(48, 69.41)]; 180 | [infoShapePath closePath]; 181 | 182 | [color0 setFill]; 183 | [infoShapePath fill]; 184 | } 185 | 186 | + (void)drawEdit 187 | { 188 | // Color Declarations 189 | UIColor *color = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; 190 | 191 | // Edit shape Drawing 192 | UIBezierPath *editPathPath = [[UIBezierPath alloc] init]; 193 | [editPathPath moveToPoint:CGPointMake(71, 2.7)]; 194 | [editPathPath addCurveToPoint:CGPointMake(71.9, 15.2) controlPoint1:CGPointMake(74.7, 5.9) controlPoint2:CGPointMake(75.1, 11.6)]; 195 | [editPathPath addLineToPoint:CGPointMake(64.5, 23.7)]; 196 | [editPathPath addLineToPoint:CGPointMake(49.9, 11.1)]; 197 | [editPathPath addLineToPoint:CGPointMake(57.3, 2.6)]; 198 | [editPathPath addCurveToPoint:CGPointMake(69.7, 1.7) controlPoint1:CGPointMake(60.4, -1.1) controlPoint2:CGPointMake(66.1, -1.5)]; 199 | [editPathPath addLineToPoint:CGPointMake(71, 2.7)]; 200 | [editPathPath addLineToPoint:CGPointMake(71, 2.7)]; 201 | [editPathPath closePath]; 202 | 203 | [editPathPath moveToPoint:CGPointMake(47.8, 13.5)]; 204 | [editPathPath addLineToPoint:CGPointMake(13.4, 53.1)]; 205 | [editPathPath addLineToPoint:CGPointMake(15.7, 55.1)]; 206 | [editPathPath addLineToPoint:CGPointMake(50.1, 15.5)]; 207 | [editPathPath addLineToPoint:CGPointMake(47.8, 13.5)]; 208 | [editPathPath addLineToPoint:CGPointMake(47.8, 13.5)]; 209 | [editPathPath closePath]; 210 | 211 | [editPathPath moveToPoint:CGPointMake(17.7, 56.7)]; 212 | [editPathPath addLineToPoint:CGPointMake(23.8, 62.2)]; 213 | [editPathPath addLineToPoint:CGPointMake(58.2, 22.6)]; 214 | [editPathPath addLineToPoint:CGPointMake(52, 17.1)]; 215 | [editPathPath addLineToPoint:CGPointMake(17.7, 56.7)]; 216 | [editPathPath addLineToPoint:CGPointMake(17.7, 56.7)]; 217 | [editPathPath closePath]; 218 | 219 | [editPathPath moveToPoint:CGPointMake(25.8, 63.8)]; 220 | [editPathPath addLineToPoint:CGPointMake(60.1, 24.2)]; 221 | [editPathPath addLineToPoint:CGPointMake(62.3, 26.1)]; 222 | [editPathPath addLineToPoint:CGPointMake(28.1, 65.7)]; 223 | [editPathPath addLineToPoint:CGPointMake(25.8, 63.8)]; 224 | [editPathPath addLineToPoint:CGPointMake(25.8, 63.8)]; 225 | [editPathPath closePath]; 226 | 227 | [editPathPath moveToPoint:CGPointMake(25.9, 68.1)]; 228 | [editPathPath addLineToPoint:CGPointMake(4.2, 79.5)]; 229 | [editPathPath addLineToPoint:CGPointMake(11.3, 55.5)]; 230 | [editPathPath addLineToPoint:CGPointMake(25.9, 68.1)]; 231 | [editPathPath closePath]; 232 | 233 | editPathPath.miterLimit = 4; 234 | editPathPath.usesEvenOddFillRule = YES; 235 | [color setFill]; 236 | [editPathPath fill]; 237 | } 238 | 239 | + (void)drawQuestion 240 | { 241 | // Color Declarations 242 | UIColor *color = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; 243 | 244 | // Questionmark Shape Drawing 245 | UIBezierPath *questionShapePath = [[UIBezierPath alloc] init]; 246 | [questionShapePath moveToPoint: CGPointMake(33.75, 54.1)]; 247 | [questionShapePath addLineToPoint: CGPointMake(44.15, 54.1)]; 248 | [questionShapePath addLineToPoint: CGPointMake(44.15, 47.5)]; 249 | [questionShapePath addCurveToPoint: CGPointMake(51.85, 37.2) controlPoint1: CGPointMake(44.15, 42.9) controlPoint2: CGPointMake(46.75, 41.2)]; 250 | [questionShapePath addCurveToPoint: CGPointMake(61.95, 19.9) controlPoint1: CGPointMake(59.05, 31.6) controlPoint2: CGPointMake(61.95, 28.5)]; 251 | [questionShapePath addCurveToPoint: CGPointMake(41.45, 2.8) controlPoint1: CGPointMake(61.95, 7.6) controlPoint2: CGPointMake(52.85, 2.8)]; 252 | [questionShapePath addCurveToPoint: CGPointMake(25.05, 5.8) controlPoint1: CGPointMake(34.75, 2.8) controlPoint2: CGPointMake(29.65, 3.8)]; 253 | [questionShapePath addLineToPoint: CGPointMake(25.05, 14.4)]; 254 | [questionShapePath addCurveToPoint: CGPointMake(38.15, 12.3) controlPoint1: CGPointMake(29.15, 13.2) controlPoint2: CGPointMake(32.35, 12.3)]; 255 | [questionShapePath addCurveToPoint: CGPointMake(49.65, 20.8) controlPoint1: CGPointMake(45.65, 12.3) controlPoint2: CGPointMake(49.65, 14.4)]; 256 | [questionShapePath addCurveToPoint: CGPointMake(43.65, 31.7) controlPoint1: CGPointMake(49.65, 26) controlPoint2: CGPointMake(47.95, 28.4)]; 257 | [questionShapePath addCurveToPoint: CGPointMake(33.75, 46.6) controlPoint1: CGPointMake(37.15, 36.9) controlPoint2: CGPointMake(33.75, 39.7)]; 258 | [questionShapePath addLineToPoint: CGPointMake(33.75, 54.1)]; 259 | [questionShapePath closePath]; 260 | 261 | [questionShapePath moveToPoint: CGPointMake(33.15, 75.4)]; 262 | [questionShapePath addLineToPoint: CGPointMake(45.35, 75.4)]; 263 | [questionShapePath addLineToPoint: CGPointMake(45.35, 63.7)]; 264 | [questionShapePath addLineToPoint: CGPointMake(33.15, 63.7)]; 265 | [questionShapePath addLineToPoint: CGPointMake(33.15, 75.4)]; 266 | [questionShapePath closePath]; 267 | 268 | [color setFill]; 269 | [questionShapePath fill]; 270 | } 271 | 272 | #pragma mark - Images 273 | 274 | + (UIImage*)imageOfCheckmark 275 | { 276 | if (imageOfCheckmark != nil) 277 | { 278 | return imageOfCheckmark; 279 | } 280 | 281 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 282 | [SCLAlertViewStyleKit drawCheckmark]; 283 | imageOfCheckmark = UIGraphicsGetImageFromCurrentImageContext(); 284 | UIGraphicsEndImageContext(); 285 | 286 | return imageOfCheckmark; 287 | } 288 | 289 | 290 | + (UIImage*)imageOfCross 291 | { 292 | if (imageOfCross != nil) 293 | { 294 | return imageOfCross; 295 | } 296 | 297 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 298 | [SCLAlertViewStyleKit drawCross]; 299 | imageOfCross = UIGraphicsGetImageFromCurrentImageContext(); 300 | UIGraphicsEndImageContext(); 301 | 302 | return imageOfCross; 303 | } 304 | 305 | + (UIImage*)imageOfNotice 306 | { 307 | if (imageOfNotice != nil) 308 | { 309 | return imageOfNotice; 310 | } 311 | 312 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 313 | [SCLAlertViewStyleKit drawNotice]; 314 | imageOfNotice = UIGraphicsGetImageFromCurrentImageContext(); 315 | UIGraphicsEndImageContext(); 316 | 317 | return imageOfNotice; 318 | } 319 | 320 | + (UIImage*)imageOfWarning 321 | { 322 | if (imageOfWarning != nil) 323 | { 324 | return imageOfWarning; 325 | } 326 | 327 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 328 | [SCLAlertViewStyleKit drawWarning]; 329 | imageOfWarning = UIGraphicsGetImageFromCurrentImageContext(); 330 | UIGraphicsEndImageContext(); 331 | 332 | return imageOfWarning; 333 | } 334 | 335 | + (UIImage*)imageOfInfo 336 | { 337 | if (imageOfInfo != nil) 338 | { 339 | return imageOfInfo; 340 | } 341 | 342 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 343 | [SCLAlertViewStyleKit drawInfo]; 344 | imageOfInfo = UIGraphicsGetImageFromCurrentImageContext(); 345 | UIGraphicsEndImageContext(); 346 | 347 | return imageOfInfo; 348 | } 349 | 350 | + (UIImage*)imageOfEdit 351 | { 352 | if (imageOfEdit != nil) 353 | { 354 | return imageOfEdit; 355 | } 356 | 357 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 358 | [SCLAlertViewStyleKit drawEdit]; 359 | imageOfEdit = UIGraphicsGetImageFromCurrentImageContext(); 360 | UIGraphicsEndImageContext(); 361 | 362 | return imageOfEdit; 363 | } 364 | 365 | + (UIImage*)imageOfQuestion 366 | { 367 | if (imageOfQuestion != nil) 368 | { 369 | return imageOfQuestion; 370 | } 371 | 372 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(80, 80), NO, 0); 373 | [SCLAlertViewStyleKit drawQuestion]; 374 | imageOfQuestion = UIGraphicsGetImageFromCurrentImageContext(); 375 | UIGraphicsEndImageContext(); 376 | 377 | return imageOfQuestion; 378 | } 379 | 380 | @end 381 | -------------------------------------------------------------------------------- /SCLAlertView/SCLButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLButton.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #if defined(__has_feature) && __has_feature(modules) 10 | @import UIKit; 11 | #else 12 | #import 13 | #endif 14 | 15 | @class SCLTimerDisplay; 16 | 17 | @interface SCLButton : UIButton 18 | 19 | typedef void (^SCLActionBlock)(void); 20 | typedef BOOL (^SCLValidationBlock)(void); 21 | typedef NSDictionary* (^CompleteButtonFormatBlock)(void); 22 | typedef NSDictionary* (^ButtonFormatBlock)(void); 23 | 24 | // Action Types 25 | typedef NS_ENUM(NSInteger, SCLActionType) 26 | { 27 | SCLNone, 28 | SCLSelector, 29 | SCLBlock 30 | }; 31 | 32 | /** Set button action type. 33 | * 34 | * Holds the button action type. 35 | */ 36 | @property SCLActionType actionType; 37 | 38 | /** Set action button block. 39 | * 40 | * TODO 41 | */ 42 | @property (copy, nonatomic) SCLActionBlock actionBlock; 43 | 44 | /** Set Validation button block. 45 | * 46 | * Set one kind of validation and keeps the alert visible until the validation is successful 47 | */ 48 | @property (copy, nonatomic) SCLValidationBlock validationBlock; 49 | 50 | /** Set Complete button format block. 51 | * 52 | * Holds the complete button format block. 53 | * Support keys : backgroundColor, borderWidth, borderColor, textColor 54 | */ 55 | @property (copy, nonatomic) CompleteButtonFormatBlock completeButtonFormatBlock; 56 | 57 | /** Set button format block. 58 | * 59 | * Holds the button format block. 60 | * Support keys : backgroundColor, borderWidth, borderColor, textColor 61 | */ 62 | @property (copy, nonatomic) ButtonFormatBlock buttonFormatBlock; 63 | 64 | /** Set SCLButton color. 65 | * 66 | * Set SCLButton color. 67 | */ 68 | @property (strong, nonatomic) UIColor *defaultBackgroundColor UI_APPEARANCE_SELECTOR; 69 | 70 | /** Set Target object. 71 | * 72 | * Target is an object that holds the information necessary to send a message to another object when an event occurs. 73 | */ 74 | @property id target; 75 | 76 | /** Set selector id. 77 | * 78 | * A selector is the name used to select a method to execute for an object, 79 | * or the unique identifier that replaces the name when the source code is compiled. 80 | */ 81 | @property SEL selector; 82 | 83 | /** Parse button configuration 84 | * 85 | * Parse ButtonFormatBlock and CompleteButtonFormatBlock setting custom configuration. 86 | * Set keys : backgroundColor, borderWidth, borderColor, textColor 87 | */ 88 | - (void)parseConfig:(NSDictionary *)buttonConfig; 89 | 90 | /** Set button timer. 91 | * 92 | * Holds the button timer, if present. 93 | */ 94 | @property (strong, nonatomic) SCLTimerDisplay *timer; 95 | 96 | /** Init method 97 | * 98 | */ 99 | - (instancetype)initWithWindowWidth:(CGFloat)windowWidth; 100 | 101 | /** Adjust width of the button according to the width of the alert and 102 | * the number of buttons. Only used when buttons are horizontally aligned. 103 | * 104 | * @param windowWidth The width of the alert. 105 | * @param numberOfButtons The number of buttons in the alert. 106 | */ 107 | - (void)adjustWidthWithWindowWidth:(CGFloat)windowWidth numberOfButtons:(NSUInteger)numberOfButtons; 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /SCLAlertView/SCLButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLButton.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "SCLButton.h" 10 | #import "SCLTimerDisplay.h" 11 | 12 | #define MARGIN_BUTTON 12.0f 13 | #define DEFAULT_WINDOW_WIDTH 240 14 | #define MIN_HEIGHT 35.0f 15 | 16 | @implementation SCLButton 17 | 18 | - (instancetype)init 19 | { 20 | self = [super init]; 21 | if (self) 22 | { 23 | [self setupWithWindowWidth:DEFAULT_WINDOW_WIDTH]; 24 | } 25 | return self; 26 | } 27 | 28 | - (instancetype)initWithWindowWidth:(CGFloat)windowWidth 29 | { 30 | self = [super init]; 31 | if (self) 32 | { 33 | [self setupWithWindowWidth:windowWidth]; 34 | } 35 | return self; 36 | } 37 | 38 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 39 | { 40 | self = [super initWithCoder:aDecoder]; 41 | if(self) 42 | { 43 | [self setupWithWindowWidth:DEFAULT_WINDOW_WIDTH]; 44 | } 45 | return self; 46 | } 47 | 48 | - (instancetype)initWithFrame:(CGRect)frame 49 | { 50 | self = [super initWithFrame:frame]; 51 | if (self) 52 | { 53 | [self setupWithWindowWidth:DEFAULT_WINDOW_WIDTH]; 54 | } 55 | return self; 56 | } 57 | 58 | - (void)setupWithWindowWidth:(CGFloat)windowWidth 59 | { 60 | self.frame = CGRectMake(0.0f, 0.0f, windowWidth - (MARGIN_BUTTON * 2), MIN_HEIGHT); 61 | self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; 62 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 63 | self.layer.cornerRadius = 3.0f; 64 | } 65 | 66 | - (void)adjustWidthWithWindowWidth:(CGFloat)windowWidth numberOfButtons:(NSUInteger)numberOfButtons 67 | { 68 | CGFloat allButtonsWidth = windowWidth - (MARGIN_BUTTON * 2); 69 | CGFloat buttonWidth = (allButtonsWidth - ((numberOfButtons - 1) * 10)) / numberOfButtons; 70 | 71 | self.frame = CGRectMake(0.0f, 0.0f, buttonWidth, MIN_HEIGHT); 72 | } 73 | 74 | - (void)setTitle:(NSString *)title forState:(UIControlState)state 75 | { 76 | [super setTitle:title forState:state]; 77 | self.titleLabel.numberOfLines = 0; 78 | 79 | // Update title frame. 80 | [self.titleLabel sizeToFit]; 81 | 82 | // Update button frame 83 | [self layoutIfNeeded]; 84 | 85 | // Get height needed to display title label completely 86 | CGFloat buttonHeight = MAX(self.titleLabel.frame.size.height, MIN_HEIGHT); 87 | 88 | // Update button frame 89 | self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, buttonHeight); 90 | } 91 | 92 | - (void)setHighlighted:(BOOL)highlighted 93 | { 94 | self.backgroundColor = (highlighted) ? [self darkerColorForColor:_defaultBackgroundColor] : _defaultBackgroundColor; 95 | [super setHighlighted:highlighted]; 96 | } 97 | 98 | - (void)setDefaultBackgroundColor:(UIColor *)defaultBackgroundColor 99 | { 100 | self.backgroundColor = _defaultBackgroundColor = defaultBackgroundColor; 101 | } 102 | 103 | - (void)setTimer:(SCLTimerDisplay *)timer 104 | { 105 | _timer = timer; 106 | [self addSubview:timer]; 107 | [timer updateFrame:self.frame.size]; 108 | timer.color = self.titleLabel.textColor; 109 | } 110 | 111 | #pragma mark - Button Apperance 112 | 113 | - (void)parseConfig:(NSDictionary *)buttonConfig 114 | { 115 | if (buttonConfig[@"backgroundColor"]) 116 | { 117 | self.defaultBackgroundColor = buttonConfig[@"backgroundColor"]; 118 | } 119 | if (buttonConfig[@"textColor"]) 120 | { 121 | [self setTitleColor:buttonConfig[@"textColor"] forState:UIControlStateNormal]; 122 | } 123 | if (buttonConfig[@"cornerRadius"]) 124 | { 125 | self.layer.cornerRadius = [buttonConfig[@"cornerRadius"] floatValue]; 126 | } 127 | if ((buttonConfig[@"borderColor"]) && (buttonConfig[@"borderWidth"])) 128 | { 129 | self.layer.borderColor = ((UIColor*)buttonConfig[@"borderColor"]).CGColor; 130 | self.layer.borderWidth = [buttonConfig[@"borderWidth"] floatValue]; 131 | } 132 | else if (buttonConfig[@"borderWidth"]) 133 | { 134 | self.layer.borderWidth = [buttonConfig[@"borderWidth"] floatValue]; 135 | } 136 | 137 | // Add Button custom font with buttonConfig parameters 138 | if (buttonConfig[@"font"]) { 139 | self.titleLabel.font = buttonConfig[@"font"]; 140 | } 141 | } 142 | 143 | #pragma mark - Helpers 144 | 145 | - (UIColor *)darkerColorForColor:(UIColor *)color 146 | { 147 | CGFloat r, g, b, a; 148 | if ([color getRed:&r green:&g blue:&b alpha:&a]) 149 | return [UIColor colorWithRed:MAX(r - 0.2f, 0.0f) 150 | green:MAX(g - 0.2f, 0.0f) 151 | blue:MAX(b - 0.2f, 0.0f) 152 | alpha:a]; 153 | return nil; 154 | } 155 | 156 | - (UIColor *)lighterColorForColor:(UIColor *)color 157 | { 158 | CGFloat r, g, b, a; 159 | if ([color getRed:&r green:&g blue:&b alpha:&a]) 160 | return [UIColor colorWithRed:MIN(r + 0.2f, 1.0f) 161 | green:MIN(g + 0.2f, 1.0f) 162 | blue:MIN(b + 0.2f, 1.0f) 163 | alpha:a]; 164 | return nil; 165 | } 166 | 167 | @end 168 | -------------------------------------------------------------------------------- /SCLAlertView/SCLMacros.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLMacros.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 10/03/15. 6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #ifndef SCL_MACROS_H 10 | #define SCL_MACROS_H 11 | 12 | #define UIColorFromHEX(rgbValue) [UIColor \ 13 | colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 14 | green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 15 | blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 16 | 17 | #define DEGREES_TO_RADIANS(degrees) ((M_PI * degrees)/ 180) 18 | #define TIMER_STEP .01 19 | #define START_DEGREE_OFFSET -90 20 | 21 | #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) 22 | #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) 23 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 24 | #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 25 | #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /SCLAlertView/SCLSwitchView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLSwitchView.h 3 | // SCLAlertView 4 | // 5 | // Created by André Felipe Santos on 27/01/16. 6 | // Copyright (c) 2016-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #if defined(__has_feature) && __has_feature(modules) 10 | @import UIKit; 11 | #else 12 | #import 13 | #endif 14 | 15 | @interface SCLSwitchView : UIView 16 | 17 | @property (strong, nonatomic) UIColor *tintColor UI_APPEARANCE_SELECTOR; 18 | @property (strong, nonatomic) UIColor *labelColor UI_APPEARANCE_SELECTOR; 19 | @property (strong, nonatomic) UIFont *labelFont UI_APPEARANCE_SELECTOR; 20 | @property (strong, nonatomic) NSString *labelText UI_APPEARANCE_SELECTOR; 21 | @property (nonatomic, getter=isSelected) BOOL selected; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /SCLAlertView/SCLSwitchView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLSwitchView.m 3 | // SCLAlertView 4 | // 5 | // Created by André Felipe Santos on 27/01/16. 6 | // Copyright (c) 2016-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "SCLSwitchView.h" 10 | #import "SCLMacros.h" 11 | 12 | @interface SCLSwitchView () 13 | 14 | @property (strong, nonatomic) UISwitch *switchKnob; 15 | @property (strong, nonatomic) UILabel *switchLabel; 16 | 17 | @end 18 | 19 | #pragma mark 20 | 21 | @implementation SCLSwitchView 22 | 23 | #pragma mark - Constructors 24 | 25 | - (instancetype)init 26 | { 27 | self = [super init]; 28 | if (self) 29 | { 30 | [self setup]; 31 | } 32 | return self; 33 | } 34 | 35 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 36 | { 37 | self = [super initWithCoder:aDecoder]; 38 | if(self) 39 | { 40 | [self setup]; 41 | } 42 | return self; 43 | } 44 | 45 | - (instancetype)initWithFrame:(CGRect)frame 46 | { 47 | self = [super initWithFrame:frame]; 48 | if (self) 49 | { 50 | [self setup]; 51 | } 52 | return self; 53 | } 54 | 55 | #pragma mark - Initialization 56 | 57 | - (void)setup 58 | { 59 | // Add switch knob 60 | self.switchKnob = [[UISwitch alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.f)]; 61 | [self addSubview:self.switchKnob]; 62 | 63 | // Add switch label 64 | CGFloat x, width, height; 65 | x = self.switchKnob.frame.size.width + 8.0f; 66 | width = self.frame.size.width - self.switchKnob.frame.size.width - 8.0f; 67 | height = self.switchKnob.frame.size.height; 68 | 69 | self.switchLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, 0.0f, width, height)]; 70 | 71 | NSString *switchFontFamily = @"HelveticaNeue-Bold"; 72 | CGFloat switchFontSize = 12.0f; 73 | 74 | self.switchLabel.numberOfLines = 1; 75 | self.switchLabel.textAlignment = NSTextAlignmentLeft; 76 | self.switchLabel.lineBreakMode = NSLineBreakByTruncatingTail; 77 | self.switchLabel.adjustsFontSizeToFitWidth = YES; 78 | self.switchLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; 79 | self.switchLabel.minimumScaleFactor = 0.5f; 80 | self.switchLabel.font = [UIFont fontWithName:switchFontFamily size:switchFontSize]; 81 | self.switchLabel.textColor = UIColorFromHEX(0x4D4D4D); 82 | 83 | [self addSubview:self.switchLabel]; 84 | } 85 | 86 | #pragma mark - Getters 87 | 88 | - (UIColor *)tintColor 89 | { 90 | return self.switchKnob.tintColor; 91 | } 92 | 93 | - (UIColor *)labelColor 94 | { 95 | return self.switchLabel.textColor; 96 | } 97 | 98 | - (UIFont *)labelFont 99 | { 100 | return self.switchLabel.font; 101 | } 102 | 103 | - (NSString *)labelText 104 | { 105 | return self.switchLabel.text; 106 | } 107 | 108 | - (BOOL)isSelected 109 | { 110 | return self.switchKnob.isOn; 111 | } 112 | 113 | #pragma mark - Setters 114 | 115 | - (void)setTintColor:(UIColor *)tintColor 116 | { 117 | self.switchKnob.onTintColor = tintColor; 118 | } 119 | 120 | - (void)setLabelColor:(UIColor *)labelColor 121 | { 122 | self.switchLabel.textColor = labelColor; 123 | } 124 | 125 | - (void)setLabelFont:(UIFont *)labelFont 126 | { 127 | self.switchLabel.font = labelFont; 128 | } 129 | 130 | - (void)setLabelText:(NSString *)labelText 131 | { 132 | self.switchLabel.text = labelText; 133 | } 134 | 135 | - (void)setSelected:(BOOL)selected 136 | { 137 | self.switchKnob.on = selected; 138 | } 139 | 140 | @end 141 | -------------------------------------------------------------------------------- /SCLAlertView/SCLTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLTextView.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/18/15. 6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #if defined(__has_feature) && __has_feature(modules) 10 | @import UIKit; 11 | #else 12 | #import 13 | #endif 14 | 15 | @interface SCLTextView : UITextField 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /SCLAlertView/SCLTextView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLTextView.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/18/15. 6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "SCLTextView.h" 10 | 11 | #define MIN_HEIGHT 30.0f 12 | 13 | @implementation SCLTextView 14 | 15 | - (instancetype)init 16 | { 17 | self = [super init]; 18 | if (self) 19 | { 20 | [self setup]; 21 | } 22 | return self; 23 | } 24 | 25 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 26 | { 27 | self = [super initWithCoder:aDecoder]; 28 | if(self) 29 | { 30 | [self setup]; 31 | } 32 | return self; 33 | } 34 | 35 | - (instancetype)initWithFrame:(CGRect)frame 36 | { 37 | self = [super initWithFrame:frame]; 38 | if (self) 39 | { 40 | [self setup]; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)setup 46 | { 47 | self.frame = CGRectMake(0.0f, 0.0f, 0.0f, MIN_HEIGHT); 48 | self.returnKeyType = UIReturnKeyDone; 49 | self.borderStyle = UITextBorderStyleRoundedRect; 50 | self.autocapitalizationType = UITextAutocapitalizationTypeSentences; 51 | self.clearButtonMode = UITextFieldViewModeWhileEditing; 52 | self.layer.masksToBounds = YES; 53 | self.layer.borderWidth = 1.0f; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /SCLAlertView/SCLTimerDisplay.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLTimerDisplay.h 3 | // SCLAlertView 4 | // 5 | // Created by Taylor Ryan on 8/18/15. 6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | // Taken from https://stackoverflow.com/questions/11783439/uibutton-with-timer 9 | 10 | #if defined(__has_feature) && __has_feature(modules) 11 | @import UIKit; 12 | #else 13 | #import 14 | #endif 15 | #import "SCLButton.h" 16 | 17 | @interface SCLTimerDisplay : UIView { 18 | CGFloat currentAngle; 19 | CGFloat currentTime; 20 | CGFloat timerLimit; 21 | CGFloat radius; 22 | CGFloat lineWidth; 23 | NSTimer *timer; 24 | SCLActionBlock completedBlock; 25 | } 26 | 27 | @property CGFloat currentAngle; 28 | @property NSInteger buttonIndex; 29 | @property (strong, nonatomic) UIColor *color; 30 | @property (assign, nonatomic) BOOL reverse; 31 | 32 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r; 33 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r lineWidth:(CGFloat)width; 34 | - (void)updateFrame:(CGSize)size; 35 | - (void)cancelTimer; 36 | - (void)stopTimer; 37 | - (void)startTimerWithTimeLimit:(int)tl completed:(SCLActionBlock)completed; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /SCLAlertView/SCLTimerDisplay.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLTimerDisplay.m 3 | // SCLAlertView 4 | // 5 | // Created by Taylor Ryan on 8/18/15. 6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "SCLTimerDisplay.h" 10 | #import "SCLMacros.h" 11 | 12 | @interface SCLTimerDisplay () 13 | 14 | @property (strong, nonatomic) UILabel *countLabel; 15 | 16 | @end 17 | 18 | @implementation SCLTimerDisplay 19 | 20 | @synthesize currentAngle; 21 | 22 | - (instancetype)initWithFrame:(CGRect)frame 23 | { 24 | self = [super initWithFrame:frame]; 25 | if (self) 26 | { 27 | self.backgroundColor = [UIColor clearColor]; 28 | currentAngle = 0.0f; 29 | } 30 | return self; 31 | } 32 | 33 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r 34 | { 35 | return [self initWithOrigin:(CGPoint)origin radius:r lineWidth:5.0f]; 36 | } 37 | 38 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r lineWidth:(CGFloat)width 39 | { 40 | self = [super initWithFrame:CGRectMake(origin.x, origin.y, r*2, r*2)]; 41 | if (self) { 42 | self.backgroundColor = [UIColor clearColor]; 43 | currentAngle = START_DEGREE_OFFSET; 44 | radius = r-(width/2); 45 | lineWidth = width; 46 | self.color = [UIColor whiteColor]; 47 | self.userInteractionEnabled = NO; 48 | 49 | // Add count label 50 | _countLabel = [[UILabel alloc] init]; 51 | _countLabel.textColor = [UIColor whiteColor]; 52 | _countLabel.backgroundColor = [UIColor clearColor]; 53 | _countLabel.font = [UIFont fontWithName: @"HelveticaNeue-Bold" size:12.0f]; 54 | _countLabel.textAlignment = NSTextAlignmentCenter; 55 | _countLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 56 | [self addSubview:_countLabel]; 57 | } 58 | return self; 59 | } 60 | 61 | - (void)updateFrame:(CGSize)size 62 | { 63 | CGFloat r = radius+(lineWidth/2); 64 | 65 | CGFloat originX = size.width - (2*r) - 5; 66 | CGFloat originY = (size.height - (2*r))/2; 67 | 68 | self.frame = CGRectMake(originX, originY, r*2, r*2); 69 | self.countLabel.frame = CGRectMake(0, 0, r*2, r*2); 70 | } 71 | 72 | - (void)drawRect:(CGRect)rect 73 | { 74 | UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(radius+(lineWidth/2), radius+(lineWidth/2)) 75 | radius:radius 76 | startAngle:DEGREES_TO_RADIANS(START_DEGREE_OFFSET) 77 | endAngle:DEGREES_TO_RADIANS(currentAngle) 78 | clockwise:YES]; 79 | [self.color setStroke]; 80 | aPath.lineWidth = lineWidth; 81 | [aPath stroke]; 82 | 83 | _countLabel.text = [NSString stringWithFormat:@"%d", (int)currentTime]; 84 | } 85 | 86 | - (void)startTimerWithTimeLimit:(int)tl completed:(SCLActionBlock)completed 87 | { 88 | if (_reverse) 89 | { 90 | currentTime = tl; 91 | } 92 | timerLimit = tl; 93 | timer = [NSTimer scheduledTimerWithTimeInterval:TIMER_STEP target:self selector:@selector(updateTimerButton:) userInfo:nil repeats:YES]; 94 | completedBlock = completed; 95 | _countLabel.textColor = _color; 96 | } 97 | 98 | - (void)cancelTimer 99 | { 100 | [timer invalidate]; 101 | } 102 | 103 | - (void)stopTimer 104 | { 105 | [timer invalidate]; 106 | if (completedBlock != nil) { 107 | completedBlock(); 108 | } 109 | } 110 | 111 | - (void)updateTimerButton:(NSTimer *)timer 112 | { 113 | if (_reverse) 114 | { 115 | currentTime -= TIMER_STEP; 116 | currentAngle = (currentTime/timerLimit) * 360 + START_DEGREE_OFFSET; 117 | 118 | if(currentTime <= 0) { 119 | [self stopTimer]; 120 | } 121 | } 122 | else { 123 | currentTime += TIMER_STEP; 124 | currentAngle = (currentTime/timerLimit) * 360 + START_DEGREE_OFFSET; 125 | 126 | if(currentAngle >= (360 + START_DEGREE_OFFSET)) { 127 | [self stopTimer]; 128 | } 129 | } 130 | [self setNeedsDisplay]; 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /SCLAlertView/UIImage+ImageEffects.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: UIImage+ImageEffects.h 3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. 4 | Version: 1.0 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2013 Apple Inc. All Rights Reserved. 45 | 46 | 47 | Copyright © 2013 Apple Inc. All rights reserved. 48 | WWDC 2013 License 49 | 50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 51 | Session. Please refer to the applicable WWDC 2013 Session for further 52 | information. 53 | 54 | IMPORTANT: This Apple software is supplied to you by Apple Inc. 55 | ("Apple") in consideration of your agreement to the following terms, and 56 | your use, installation, modification or redistribution of this Apple 57 | software constitutes acceptance of these terms. If you do not agree with 58 | these terms, please do not use, install, modify or redistribute this 59 | Apple software. 60 | 61 | In consideration of your agreement to abide by the following terms, and 62 | subject to these terms, Apple grants you a non-exclusive license, under 63 | Apple's copyrights in this original Apple software (the "Apple 64 | Software"), to use, reproduce, modify and redistribute the Apple 65 | Software, with or without modifications, in source and/or binary forms; 66 | provided that if you redistribute the Apple Software in its entirety and 67 | without modifications, you must retain this notice and the following 68 | text and disclaimers in all such redistributions of the Apple Software. 69 | Neither the name, trademarks, service marks or logos of Apple Inc. may 70 | be used to endorse or promote products derived from the Apple Software 71 | without specific prior written permission from Apple. Except as 72 | expressly stated in this notice, no other rights or licenses, express or 73 | implied, are granted by Apple herein, including but not limited to any 74 | patent rights that may be infringed by your derivative works or by other 75 | works in which the Apple Software may be incorporated. 76 | 77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES 78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE 79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR 80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 82 | 83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | EA1002 93 | 5/3/2013 94 | */ 95 | 96 | #if defined(__has_feature) && __has_feature(modules) 97 | @import UIKit; 98 | #else 99 | #import 100 | #endif 101 | 102 | @interface UIImage (ImageEffects) 103 | 104 | - (UIImage *)applyLightEffect; 105 | - (UIImage *)applyExtraLightEffect; 106 | - (UIImage *)applyDarkEffect; 107 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor; 108 | 109 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; 110 | 111 | + (UIImage *)imageWithColor:(UIColor *)color; 112 | + (UIImage *)convertViewToImage; 113 | + (UIImage *)convertViewToImage:(UIView *)view; 114 | 115 | @end 116 | -------------------------------------------------------------------------------- /SCLAlertView/UIImage+ImageEffects.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: UIImage+ImageEffects.m 3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. 4 | Version: 1.0 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2013 Apple Inc. All Rights Reserved. 45 | 46 | 47 | Copyright © 2013 Apple Inc. All rights reserved. 48 | WWDC 2013 License 49 | 50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 51 | Session. Please refer to the applicable WWDC 2013 Session for further 52 | information. 53 | 54 | IMPORTANT: This Apple software is supplied to you by Apple Inc. 55 | ("Apple") in consideration of your agreement to the following terms, and 56 | your use, installation, modification or redistribution of this Apple 57 | software constitutes acceptance of these terms. If you do not agree with 58 | these terms, please do not use, install, modify or redistribute this 59 | Apple software. 60 | 61 | In consideration of your agreement to abide by the following terms, and 62 | subject to these terms, Apple grants you a non-exclusive license, under 63 | Apple's copyrights in this original Apple software (the "Apple 64 | Software"), to use, reproduce, modify and redistribute the Apple 65 | Software, with or without modifications, in source and/or binary forms; 66 | provided that if you redistribute the Apple Software in its entirety and 67 | without modifications, you must retain this notice and the following 68 | text and disclaimers in all such redistributions of the Apple Software. 69 | Neither the name, trademarks, service marks or logos of Apple Inc. may 70 | be used to endorse or promote products derived from the Apple Software 71 | without specific prior written permission from Apple. Except as 72 | expressly stated in this notice, no other rights or licenses, express or 73 | implied, are granted by Apple herein, including but not limited to any 74 | patent rights that may be infringed by your derivative works or by other 75 | works in which the Apple Software may be incorporated. 76 | 77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES 78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE 79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR 80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 82 | 83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | EA1002 93 | 5/3/2013 94 | */ 95 | 96 | #import "UIImage+ImageEffects.h" 97 | #import "SCLMacros.h" 98 | 99 | #if defined(__has_feature) && __has_feature(modules) 100 | @import Accelerate; 101 | #else 102 | #import 103 | #endif 104 | #import 105 | 106 | 107 | @implementation UIImage (ImageEffects) 108 | 109 | 110 | - (UIImage *)applyLightEffect 111 | { 112 | UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3]; 113 | return [self applyBlurWithRadius:30 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 114 | } 115 | 116 | 117 | - (UIImage *)applyExtraLightEffect 118 | { 119 | UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82]; 120 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 121 | } 122 | 123 | 124 | - (UIImage *)applyDarkEffect 125 | { 126 | UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73]; 127 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 128 | } 129 | 130 | 131 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor 132 | { 133 | const CGFloat EffectColorAlpha = 0.6; 134 | UIColor *effectColor = tintColor; 135 | NSUInteger componentCount = CGColorGetNumberOfComponents(tintColor.CGColor); 136 | if (componentCount == 2) { 137 | CGFloat b; 138 | if ([tintColor getWhite:&b alpha:NULL]) { 139 | effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha]; 140 | } 141 | } 142 | else { 143 | CGFloat r, g, b; 144 | if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) { 145 | effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha]; 146 | } 147 | } 148 | return [self applyBlurWithRadius:10 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil]; 149 | } 150 | 151 | 152 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage 153 | { 154 | // Check pre-conditions. 155 | if (self.size.width < 1 || self.size.height < 1) { 156 | NSLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self); 157 | return nil; 158 | } 159 | if (!self.CGImage) { 160 | NSLog (@"*** error: image must be backed by a CGImage: %@", self); 161 | return nil; 162 | } 163 | if (maskImage && !maskImage.CGImage) { 164 | NSLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage); 165 | return nil; 166 | } 167 | 168 | CGRect imageRect = { CGPointZero, self.size }; 169 | UIImage *effectImage = self; 170 | 171 | BOOL hasBlur = blurRadius > __FLT_EPSILON__; 172 | BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__; 173 | if (hasBlur || hasSaturationChange) { 174 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 175 | CGContextRef effectInContext = UIGraphicsGetCurrentContext(); 176 | CGContextScaleCTM(effectInContext, 1.0, -1.0); 177 | CGContextTranslateCTM(effectInContext, 0, -self.size.height); 178 | CGContextDrawImage(effectInContext, imageRect, self.CGImage); 179 | 180 | vImage_Buffer effectInBuffer; 181 | effectInBuffer.data = CGBitmapContextGetData(effectInContext); 182 | effectInBuffer.width = CGBitmapContextGetWidth(effectInContext); 183 | effectInBuffer.height = CGBitmapContextGetHeight(effectInContext); 184 | effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext); 185 | 186 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 187 | CGContextRef effectOutContext = UIGraphicsGetCurrentContext(); 188 | vImage_Buffer effectOutBuffer; 189 | effectOutBuffer.data = CGBitmapContextGetData(effectOutContext); 190 | effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext); 191 | effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext); 192 | effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext); 193 | 194 | if (hasBlur) { 195 | // A description of how to compute the box kernel width from the Gaussian 196 | // radius (aka standard deviation) appears in the SVG spec: 197 | // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement 198 | // 199 | // For larger values of 's' (s >= 2.0), an approximation can be used: Three 200 | // successive box-blurs build a piece-wise quadratic convolution kernel, which 201 | // approximates the Gaussian kernel to within roughly 3%. 202 | // 203 | // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) 204 | // 205 | // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. 206 | // 207 | CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale]; 208 | uint32_t radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5); 209 | if (radius % 2 != 1) { 210 | radius += 1; // force radius to be odd so that the three box-blur methodology works. 211 | } 212 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 213 | vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 214 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 215 | } 216 | BOOL effectImageBuffersAreSwapped = NO; 217 | if (hasSaturationChange) { 218 | CGFloat s = saturationDeltaFactor; 219 | CGFloat floatingPointSaturationMatrix[] = { 220 | 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0, 221 | 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0, 222 | 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0, 223 | 0, 0, 0, 1, 224 | }; 225 | const int32_t divisor = 256; 226 | NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]); 227 | int16_t saturationMatrix[matrixSize]; 228 | for (NSUInteger i = 0; i < matrixSize; ++i) { 229 | saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor); 230 | } 231 | if (hasBlur) { 232 | vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); 233 | effectImageBuffersAreSwapped = YES; 234 | } 235 | else { 236 | vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); 237 | } 238 | } 239 | if (!effectImageBuffersAreSwapped) 240 | effectImage = UIGraphicsGetImageFromCurrentImageContext(); 241 | UIGraphicsEndImageContext(); 242 | 243 | if (effectImageBuffersAreSwapped) 244 | effectImage = UIGraphicsGetImageFromCurrentImageContext(); 245 | UIGraphicsEndImageContext(); 246 | } 247 | 248 | // Set up output context. 249 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 250 | CGContextRef outputContext = UIGraphicsGetCurrentContext(); 251 | CGContextScaleCTM(outputContext, 1.0, -1.0); 252 | CGContextTranslateCTM(outputContext, 0, -self.size.height); 253 | 254 | // Draw base image. 255 | CGContextDrawImage(outputContext, imageRect, self.CGImage); 256 | 257 | // Draw effect image. 258 | if (hasBlur) { 259 | CGContextSaveGState(outputContext); 260 | if (maskImage) { 261 | CGContextClipToMask(outputContext, imageRect, maskImage.CGImage); 262 | } 263 | CGContextDrawImage(outputContext, imageRect, effectImage.CGImage); 264 | CGContextRestoreGState(outputContext); 265 | } 266 | 267 | // Add in color tint. 268 | if (tintColor) { 269 | CGContextSaveGState(outputContext); 270 | CGContextSetFillColorWithColor(outputContext, tintColor.CGColor); 271 | CGContextFillRect(outputContext, imageRect); 272 | CGContextRestoreGState(outputContext); 273 | } 274 | 275 | // Output image is ready. 276 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); 277 | UIGraphicsEndImageContext(); 278 | 279 | return outputImage; 280 | } 281 | 282 | + (UIImage *)imageWithColor:(UIColor *)color 283 | { 284 | CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f); 285 | UIGraphicsBeginImageContext(rect.size); 286 | CGContextRef context = UIGraphicsGetCurrentContext(); 287 | 288 | CGContextSetFillColorWithColor(context, [color CGColor]); 289 | CGContextFillRect(context, rect); 290 | 291 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 292 | UIGraphicsEndImageContext(); 293 | 294 | return image; 295 | } 296 | 297 | + (UIImage *)convertViewToImage 298 | { 299 | UIWindow *keyWindow = [[UIApplication sharedApplication]keyWindow]; 300 | CGRect rect = [keyWindow bounds]; 301 | UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f); 302 | CGContextRef context = UIGraphicsGetCurrentContext(); 303 | [keyWindow.layer renderInContext:context]; 304 | UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext(); 305 | UIGraphicsEndImageContext(); 306 | 307 | return capturedScreen; 308 | } 309 | 310 | + (UIImage *)convertViewToImage:(UIView *)view 311 | { 312 | CGFloat scale = [UIScreen mainScreen].scale; 313 | UIImage *capturedScreen; 314 | 315 | //Optimized/fast method for rendering a UIView as image on iOS 7 and later versions. 316 | UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, scale); 317 | [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; 318 | capturedScreen = UIGraphicsGetImageFromCurrentImageContext(); 319 | UIGraphicsEndImageContext(); 320 | 321 | return capturedScreen; 322 | } 323 | 324 | @end 325 | -------------------------------------------------------------------------------- /SCLAlertViewExample/AppDelegate/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SCLAlertViewExample/AppDelegate/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SCLAlertViewExample/Base.lproj/Storyboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 39 | 48 | 57 | 66 | 75 | 84 | 93 | 102 | 111 | 120 | 129 | 138 | 147 | 156 | 165 | 174 | 183 | 192 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | -------------------------------------------------------------------------------- /SCLAlertViewExample/Category/UIViewController+Alert.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+Alert.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 31/10/20. 6 | // Copyright © 2020 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface UIViewController (Alert) 15 | 16 | typedef void (^ActionBlock)(void); 17 | 18 | - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message actionBlock:(nullable ActionBlock)actionBlock; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /SCLAlertViewExample/Category/UIViewController+Alert.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+Alert.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 31/10/20. 6 | // Copyright © 2020 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+Alert.h" 10 | 11 | @implementation UIViewController (Alert) 12 | 13 | - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message actionBlock:(nullable ActionBlock)actionBlock 14 | { 15 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title 16 | message:message 17 | preferredStyle:UIAlertControllerStyleAlert]; 18 | 19 | UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" 20 | style:UIAlertActionStyleDefault 21 | handler:^(UIAlertAction * action) { 22 | [alertController dismissViewControllerAnimated:YES completion:nil]; 23 | if (actionBlock) { 24 | actionBlock(); 25 | } 26 | }]; 27 | [alertController addAction:okAction]; 28 | 29 | [self presentViewController:alertController animated:YES completion:nil]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /SCLAlertViewExample/Fonts/comic-sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Fonts/comic-sans.ttf -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "icon_29x29-1.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "icon_58x58.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon_87x87.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "icon_80x80.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "icon_120x120.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "icon_57x57.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "icon_57x57@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon_120x120-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon_180x180.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "icon_29x29.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "icon_58x58-1.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "icon_40x40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "icon_80x80-1.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "icon_50x50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "icon_50x50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "icon_72x72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "icon_72x72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "icon_76x76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "icon_152x152.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "83.5x83.5", 119 | "idiom" : "ipad", 120 | "filename" : "icon_167x167.png", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_120x120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_120x120-1.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_120x120.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_152x152.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_167x167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_167x167.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_180x180.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_29x29-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_29x29-1.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_29x29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_29x29.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_40x40.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_50x50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_50x50.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_50x50@2x.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_57x57.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_57x57@2x.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_58x58-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_58x58-1.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_58x58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_58x58.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_72x72.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_72x72@2x.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_76x76.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_80x80-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_80x80-1.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_80x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_80x80.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_87x87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/AppIcon.appiconset/icon_87x87.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "1x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "extent" : "full-screen", 14 | "minimum-system-version" : "7.0", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "portrait", 19 | "idiom" : "ipad", 20 | "extent" : "full-screen", 21 | "minimum-system-version" : "7.0", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "landscape", 26 | "idiom" : "ipad", 27 | "extent" : "full-screen", 28 | "minimum-system-version" : "7.0", 29 | "scale" : "2x" 30 | } 31 | ], 32 | "info" : { 33 | "version" : 1, 34 | "author" : "xcode" 35 | } 36 | } -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/git.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "git.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/git.imageset/git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/git.imageset/git.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/switch.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "switch.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SCLAlertViewExample/Images.xcassets/switch.imageset/switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Images.xcassets/switch.imageset/switch.png -------------------------------------------------------------------------------- /SCLAlertViewExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Storyboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | UIInterfaceOrientationPortraitUpsideDown 39 | 40 | UIAppFonts 41 | 42 | comic-sans.ttf 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /SCLAlertViewExample/SCLAlertView-Objective-C-prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #import 17 | #endif 18 | -------------------------------------------------------------------------------- /SCLAlertViewExample/Sounds/right_answer.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/SCLAlertViewExample/Sounds/right_answer.mp3 -------------------------------------------------------------------------------- /SCLAlertViewExample/ViewController/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | - (IBAction)showSuccess:(id)sender; 14 | - (IBAction)showSuccessWithHorizontalButtons:(id)sender; 15 | - (IBAction)showError:(id)sender; 16 | - (IBAction)showNotice:(id)sender; 17 | - (IBAction)showWarning:(id)sender; 18 | - (IBAction)showInfo:(id)sender; 19 | - (IBAction)showEdit:(id)sender; 20 | - (IBAction)showEditWithHorizontalButtons:(id)sender; 21 | - (IBAction)ShowAdvancedWithHorizontalButtons:(id)sender; 22 | - (IBAction)showCustom:(id)sender; 23 | - (IBAction)showValidation:(id)sender; 24 | - (IBAction)showValidationWithHorizontalButtons:(id)sender; 25 | - (IBAction)showWaiting:(id)sender; 26 | 27 | @end 28 | 29 | -------------------------------------------------------------------------------- /SCLAlertViewExample/ViewController/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SCLAlertView.h" 11 | #import "UIViewController+Alert.h" 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | NSString *kSuccessTitle = @"Congratulations"; 18 | NSString *kErrorTitle = @"Connection error"; 19 | NSString *kNoticeTitle = @"Notice"; 20 | NSString *kWarningTitle = @"Warning"; 21 | NSString *kInfoTitle = @"Info"; 22 | NSString *kSubtitle = @"You've just displayed this awesome Pop Up View"; 23 | NSString *kButtonTitle = @"Done"; 24 | NSString *kAttributeTitle = @"Attributed string operation successfully completed."; 25 | 26 | @implementation ViewController 27 | 28 | - (IBAction)showSuccess:(id)sender 29 | { 30 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow]; 31 | 32 | SCLButton *button = [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; 33 | 34 | button.buttonFormatBlock = ^NSDictionary* (void) 35 | { 36 | NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init]; 37 | 38 | buttonConfig[@"backgroundColor"] = [UIColor whiteColor]; 39 | buttonConfig[@"textColor"] = [UIColor blackColor]; 40 | buttonConfig[@"borderWidth"] = @2.0f; 41 | buttonConfig[@"borderColor"] = [UIColor greenColor]; 42 | 43 | return buttonConfig; 44 | }; 45 | 46 | [alert addButton:@"Second Button" actionBlock:^(void) { 47 | NSLog(@"Second button tapped"); 48 | }]; 49 | 50 | alert.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/right_answer.mp3", [NSBundle mainBundle].resourcePath]]; 51 | 52 | [alert showSuccess:kSuccessTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 53 | } 54 | 55 | - (IBAction)showSuccessWithHorizontalButtons:(id)sender { 56 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow]; 57 | [alert setHorizontalButtons:YES]; 58 | 59 | SCLButton *button = [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; 60 | 61 | button.buttonFormatBlock = ^NSDictionary* (void) 62 | { 63 | NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init]; 64 | 65 | buttonConfig[@"backgroundColor"] = [UIColor whiteColor]; 66 | buttonConfig[@"textColor"] = [UIColor blackColor]; 67 | buttonConfig[@"borderWidth"] = @2.0f; 68 | buttonConfig[@"borderColor"] = [UIColor greenColor]; 69 | 70 | return buttonConfig; 71 | }; 72 | 73 | [alert addButton:@"Second Button" actionBlock:^(void) { 74 | NSLog(@"Second button tapped"); 75 | }]; 76 | 77 | alert.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/right_answer.mp3", [NSBundle mainBundle].resourcePath]]; 78 | 79 | [alert showSuccess:kSuccessTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 80 | } 81 | 82 | - (IBAction)showError:(id)sender 83 | { 84 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 85 | 86 | [alert showError:self title:@"An error with two title is presented ..." 87 | subTitle:@"You have not saved your Submission yet. Please save the Submission before accessing the Responses list. Blah de blah de blah, blah. Blah de blah de blah, blah.Blah de blah de blah, blah.Blah de blah de blah, blah.Blah de blah de blah, blah.Blah de blah de blah, End." 88 | closeButtonTitle:@"OK" duration:0.0f]; 89 | } 90 | 91 | - (IBAction)showNotice:(id)sender 92 | { 93 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 94 | 95 | alert.backgroundType = SCLAlertViewBackgroundBlur; 96 | [alert showNotice:self title:kNoticeTitle subTitle:@"You've just displayed this awesome Pop Up View with blur effect" closeButtonTitle:kButtonTitle duration:0.0f]; 97 | } 98 | 99 | - (IBAction)showWarning:(id)sender 100 | { 101 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 102 | 103 | [alert showWarning:self title:kWarningTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 104 | } 105 | 106 | - (IBAction)showInfo:(id)sender 107 | { 108 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 109 | 110 | alert.shouldDismissOnTapOutside = YES; 111 | [alert alertIsDismissed:^{ 112 | NSLog(@"SCLAlertView dismissed!"); 113 | }]; 114 | 115 | [alert showInfo:self title:kInfoTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 116 | } 117 | 118 | - (IBAction)showEdit:(id)sender 119 | { 120 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 121 | 122 | SCLTextView *textField = [alert addTextField:@"Enter your name" setDefaultText:nil]; 123 | [alert addButton:@"Show Name" actionBlock:^(void) { 124 | NSLog(@"Text value: %@", textField.text); 125 | }]; 126 | 127 | [alert showEdit:self title:kInfoTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 128 | } 129 | 130 | - (IBAction)showEditWithHorizontalButtons:(id)sender 131 | { 132 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 133 | [alert setHorizontalButtons:YES]; 134 | 135 | SCLTextView *textField = [alert addTextField:@"Enter your name" setDefaultText:nil]; 136 | alert.hideAnimationType = SCLAlertViewHideAnimationSimplyDisappear; 137 | [alert addButton:@"Show Name" actionBlock:^(void) { 138 | NSLog(@"Text value: %@", textField.text); 139 | }]; 140 | 141 | [alert showEdit:self title:kInfoTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 142 | } 143 | 144 | - (IBAction)showAdvanced:(id)sender 145 | { 146 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 147 | 148 | alert.backgroundViewColor = [UIColor cyanColor]; 149 | 150 | [alert setTitleFontFamily:@"Superclarendon" withSize:20.0f]; 151 | [alert setBodyTextFontFamily:@"TrebuchetMS" withSize:14.0f]; 152 | [alert setButtonsTextFontFamily:@"Baskerville" withSize:14.0f]; 153 | 154 | [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; 155 | 156 | [alert addButton:@"Second Button" actionBlock:^(void) { 157 | NSLog(@"Second button tapped"); 158 | }]; 159 | 160 | SCLTextView *textField = [alert addTextField:@"Enter your name" setDefaultText:nil]; 161 | 162 | [alert addButton:@"Show Name" actionBlock:^(void) { 163 | NSLog(@"Text value: %@", textField.text); 164 | }]; 165 | 166 | alert.completeButtonFormatBlock = ^NSDictionary* (void) 167 | { 168 | NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init]; 169 | 170 | buttonConfig[@"backgroundColor"] = [UIColor greenColor]; 171 | buttonConfig[@"borderColor"] = [UIColor blackColor]; 172 | buttonConfig[@"borderWidth"] = @"1.0f"; 173 | buttonConfig[@"textColor"] = [UIColor blackColor]; 174 | 175 | return buttonConfig; 176 | }; 177 | 178 | alert.attributedFormatBlock = ^NSAttributedString* (NSString *value) 179 | { 180 | NSMutableAttributedString *subTitle = [[NSMutableAttributedString alloc]initWithString:value]; 181 | 182 | NSRange redRange = [value rangeOfString:@"Attributed" options:NSCaseInsensitiveSearch]; 183 | [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; 184 | 185 | NSRange greenRange = [value rangeOfString:@"successfully" options:NSCaseInsensitiveSearch]; 186 | [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor brownColor] range:greenRange]; 187 | 188 | NSRange underline = [value rangeOfString:@"completed" options:NSCaseInsensitiveSearch]; 189 | [subTitle addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)} range:underline]; 190 | 191 | return subTitle; 192 | }; 193 | 194 | [alert showTitle:self title:@"Congratulations" subTitle:kAttributeTitle style:SCLAlertViewStyleSuccess closeButtonTitle:@"Done" duration:0.0f]; 195 | } 196 | 197 | - (IBAction)ShowAdvancedWithHorizontalButtons:(id)sender 198 | { 199 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 200 | [alert setHorizontalButtons:YES]; 201 | 202 | alert.backgroundViewColor = [UIColor cyanColor]; 203 | 204 | [alert setTitleFontFamily:@"Superclarendon" withSize:20.0f]; 205 | [alert setBodyTextFontFamily:@"TrebuchetMS" withSize:14.0f]; 206 | [alert setButtonsTextFontFamily:@"Baskerville" withSize:14.0f]; 207 | 208 | [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; 209 | 210 | [alert addButton:@"Second Button" actionBlock:^(void) { 211 | NSLog(@"Second button tapped"); 212 | }]; 213 | 214 | SCLTextView *textField = [alert addTextField:@"Enter your name" setDefaultText:nil]; 215 | 216 | [alert addButton:@"Show Name" actionBlock:^(void) { 217 | NSLog(@"Text value: %@", textField.text); 218 | }]; 219 | 220 | alert.completeButtonFormatBlock = ^NSDictionary* (void) 221 | { 222 | NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init]; 223 | 224 | buttonConfig[@"backgroundColor"] = [UIColor greenColor]; 225 | buttonConfig[@"borderColor"] = [UIColor blackColor]; 226 | buttonConfig[@"borderWidth"] = @"1.0f"; 227 | buttonConfig[@"textColor"] = [UIColor blackColor]; 228 | 229 | return buttonConfig; 230 | }; 231 | 232 | alert.attributedFormatBlock = ^NSAttributedString* (NSString *value) 233 | { 234 | NSMutableAttributedString *subTitle = [[NSMutableAttributedString alloc]initWithString:value]; 235 | 236 | NSRange redRange = [value rangeOfString:@"Attributed" options:NSCaseInsensitiveSearch]; 237 | [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; 238 | 239 | NSRange greenRange = [value rangeOfString:@"successfully" options:NSCaseInsensitiveSearch]; 240 | [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor brownColor] range:greenRange]; 241 | 242 | NSRange underline = [value rangeOfString:@"completed" options:NSCaseInsensitiveSearch]; 243 | [subTitle addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)} range:underline]; 244 | 245 | return subTitle; 246 | }; 247 | 248 | [alert showTitle:self title:@"Congratulations" subTitle:kAttributeTitle style:SCLAlertViewStyleSuccess closeButtonTitle:@"Done" duration:0.0f]; 249 | } 250 | 251 | - (IBAction)showWithDuration:(id)sender 252 | { 253 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 254 | 255 | [alert showNotice:self title:kNoticeTitle subTitle:@"You've just displayed this awesome Pop Up View with 5 seconds duration" closeButtonTitle:nil duration:5.0f]; 256 | } 257 | 258 | - (IBAction)showCustom:(id)sender 259 | { 260 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 261 | 262 | UIColor *color = [UIColor colorWithRed:65.0/255.0 green:64.0/255.0 blue:144.0/255.0 alpha:1.0]; 263 | [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]; 264 | } 265 | 266 | - (IBAction)showValidation:(id)sender 267 | { 268 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 269 | 270 | SCLTextView *evenField = [alert addTextField:@"Enter an even number" setDefaultText:nil]; 271 | evenField.keyboardType = UIKeyboardTypeNumberPad; 272 | 273 | SCLTextView *oddField = [alert addTextField:@"Enter an odd number" setDefaultText:nil]; 274 | oddField.keyboardType = UIKeyboardTypeNumberPad; 275 | 276 | __weak __typeof(self) weakSelf = self; 277 | 278 | [alert addButton:@"Test Validation" validationBlock:^BOOL{ 279 | if (evenField.text.length == 0) 280 | { 281 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"You forgot to add an even number." actionBlock:^{ 282 | [evenField becomeFirstResponder]; 283 | }]; 284 | return NO; 285 | } 286 | 287 | if (oddField.text.length == 0) 288 | { 289 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"You forgot to add an odd number." actionBlock:^{ 290 | [oddField becomeFirstResponder]; 291 | }]; 292 | return NO; 293 | } 294 | 295 | NSInteger evenFieldEntry = (evenField.text).integerValue; 296 | BOOL evenFieldPassedValidation = evenFieldEntry % 2 == 0; 297 | 298 | if (!evenFieldPassedValidation) 299 | { 300 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"That is not an even number." actionBlock:^{ 301 | [evenField becomeFirstResponder]; 302 | }]; 303 | return NO; 304 | } 305 | 306 | NSInteger oddFieldEntry = (oddField.text).integerValue; 307 | BOOL oddFieldPassedValidation = oddFieldEntry % 2 == 1; 308 | 309 | if (!oddFieldPassedValidation) 310 | { 311 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"That is not an odd number." actionBlock:^{ 312 | [oddField becomeFirstResponder]; 313 | }]; 314 | return NO; 315 | } 316 | return YES; 317 | } actionBlock:^{ 318 | [weakSelf showAlertWithTitle:@"Great Job!" message:@"Thanks for playing." actionBlock:nil]; 319 | }]; 320 | 321 | [alert showEdit:self title:@"Validation" subTitle:@"Ensure the data is correct before dismissing!" closeButtonTitle:@"Cancel" duration:0]; 322 | } 323 | 324 | - (IBAction)showValidationWithHorizontalButtons:(id)sender 325 | { 326 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 327 | [alert setHorizontalButtons:YES]; 328 | 329 | SCLTextView *evenField = [alert addTextField:@"Enter an even number" setDefaultText:nil]; 330 | evenField.keyboardType = UIKeyboardTypeNumberPad; 331 | 332 | SCLTextView *oddField = [alert addTextField:@"Enter an odd number" setDefaultText:nil]; 333 | oddField.keyboardType = UIKeyboardTypeNumberPad; 334 | 335 | __weak __typeof(self) weakSelf = self; 336 | 337 | [alert addButton:@"Test Validation" validationBlock:^BOOL{ 338 | if (evenField.text.length == 0) 339 | { 340 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"You forgot to add an even number." actionBlock:^{ 341 | [evenField becomeFirstResponder]; 342 | }]; 343 | return NO; 344 | } 345 | 346 | if (oddField.text.length == 0) 347 | { 348 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"You forgot to add an odd number." actionBlock:^{ 349 | [oddField becomeFirstResponder]; 350 | }]; 351 | return NO; 352 | } 353 | 354 | NSInteger evenFieldEntry = (evenField.text).integerValue; 355 | BOOL evenFieldPassedValidation = evenFieldEntry % 2 == 0; 356 | 357 | if (!evenFieldPassedValidation) 358 | { 359 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"That is not an even number." actionBlock:^{ 360 | [evenField becomeFirstResponder]; 361 | }]; 362 | return NO; 363 | } 364 | 365 | NSInteger oddFieldEntry = (oddField.text).integerValue; 366 | BOOL oddFieldPassedValidation = oddFieldEntry % 2 == 1; 367 | 368 | if (!oddFieldPassedValidation) 369 | { 370 | [weakSelf showAlertWithTitle:@"Whoops!" message:@"That is not an odd number." actionBlock:^{ 371 | [oddField becomeFirstResponder]; 372 | }]; 373 | return NO; 374 | } 375 | return YES; 376 | } actionBlock:^{ 377 | [weakSelf showAlertWithTitle:@"Great Job!" message:@"Thanks for playing." actionBlock:nil]; 378 | }]; 379 | 380 | [alert showEdit:self title:@"Validation" subTitle:@"Ensure the data is correct before dismissing!" closeButtonTitle:@"Cancel" duration:0]; 381 | } 382 | 383 | - (IBAction)showWaiting:(id)sender 384 | { 385 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 386 | 387 | alert.showAnimationType = SCLAlertViewShowAnimationSlideInToCenter; 388 | alert.hideAnimationType = SCLAlertViewHideAnimationSlideOutFromCenter; 389 | 390 | alert.backgroundType = SCLAlertViewBackgroundTransparent; 391 | 392 | [alert showWaiting:self title:@"Waiting..." 393 | subTitle:@"You've just displayed this awesome Pop Up View with transparent background" 394 | closeButtonTitle:nil duration:5.0f]; 395 | } 396 | 397 | - (IBAction)showTimer:(id)sender 398 | { 399 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 400 | [alert addTimerToButtonIndex:0 reverse:YES]; 401 | [alert showInfo:self title:@"Countdown Timer" 402 | subTitle:@"This alert has a duration set, and a countdown timer on the Dismiss button to show how long is left." 403 | closeButtonTitle:@"Dismiss" duration:10.0f]; 404 | } 405 | 406 | - (IBAction)showQuestion:(id)sender 407 | { 408 | SCLAlertView *alert = [[SCLAlertView alloc] init]; 409 | 410 | [alert showQuestion:self title:@"Question?" subTitle:kSubtitle closeButtonTitle:@"Dismiss" duration:0.0f]; 411 | } 412 | 413 | - (IBAction)showSwitch:(id)sender { 414 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow]; 415 | alert.tintTopCircle = NO; 416 | alert.iconTintColor = [UIColor brownColor]; 417 | alert.useLargerIcon = YES; 418 | alert.cornerRadius = 13.0f; 419 | 420 | [alert addSwitchViewWithLabel:@"Don't show again".uppercaseString]; 421 | [[SCLSwitchView appearance] setTintColor:[UIColor brownColor]]; 422 | 423 | SCLButton *button = [alert addButton:@"Done" target:self selector:@selector(firstButton)]; 424 | 425 | button.buttonFormatBlock = ^NSDictionary* (void) { 426 | NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init]; 427 | buttonConfig[@"cornerRadius"] = @"17.5f"; 428 | 429 | return buttonConfig; 430 | }; 431 | 432 | [alert showCustom:self image:[UIImage imageNamed:@"switch"] color:[UIColor brownColor] title:kInfoTitle subTitle:kSubtitle closeButtonTitle:nil duration:0.0f]; 433 | } 434 | 435 | - (void)firstButton 436 | { 437 | NSLog(@"First button tapped"); 438 | } 439 | 440 | - (IBAction)showWithButtonCustom:(id)sender 441 | { 442 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow]; 443 | 444 | SCLButton *button = [alert addButton:@"First Button" target:self selector:@selector(firstButton)]; 445 | 446 | button.buttonFormatBlock = ^NSDictionary* (void) 447 | { 448 | NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init]; 449 | 450 | buttonConfig[@"backgroundColor"] = [UIColor whiteColor]; 451 | buttonConfig[@"textColor"] = [UIColor blackColor]; 452 | buttonConfig[@"borderWidth"] = @2.0f; 453 | buttonConfig[@"borderColor"] = [UIColor greenColor]; 454 | buttonConfig[@"font"] = [UIFont fontWithName:@"ComicSansMS" size:13]; 455 | 456 | return buttonConfig; 457 | }; 458 | 459 | [alert addButton:@"Second Button" actionBlock:^(void) { 460 | NSLog(@"Second button tapped"); 461 | }]; 462 | 463 | alert.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/right_answer.mp3", [NSBundle mainBundle].resourcePath]]; 464 | 465 | [alert showSuccess:kSuccessTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f]; 466 | } 467 | 468 | @end 469 | -------------------------------------------------------------------------------- /SCLAlertViewExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SCLAlertView 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SCLAlertViewFramework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SCLAlertViewFramework/SCLAlertViewFramework.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertViewFramework.h 3 | // SCLAlertView 4 | // 5 | // Created by Eugene Tulusha on 9/13/16. 6 | // Copyright © 2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | @import Foundation; 10 | 11 | //! Project version number for CryptoSwift. 12 | FOUNDATION_EXPORT double SCLAlertViewFrameworkVersionNumber; 13 | 14 | //! Project version string for CryptoSwift. 15 | FOUNDATION_EXPORT const unsigned char SCLAlertViewFrameworkVersionString[]; 16 | 17 | #import "SCLAlertView.h" 18 | -------------------------------------------------------------------------------- /SCLAlertViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SCLAlertViewTests/SCLAlertViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCLAlertViewTests.m 3 | // SCLAlertViewTests 4 | // 5 | // Created by Diogo Autilio on 9/26/14. 6 | // Copyright (c) 2014-2016 AnyKey Entertainment. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface SCLAlertViewTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation SCLAlertViewTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ScreenShots/ScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot2.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot3.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot4.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot5.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot6.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot7.png -------------------------------------------------------------------------------- /ScreenShots/ScreenShot8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogo/SCLAlertView/5f7ef783fcb845606800bf8da40269d611451734/ScreenShots/ScreenShot8.png --------------------------------------------------------------------------------