├── .gitignore
├── .travis.yml
├── Example
├── Podfile
├── Podfile.lock
├── Pods
│ ├── Local Podspecs
│ │ └── ZHPopupView.podspec.json
│ ├── Manifest.lock
│ ├── Pods.xcodeproj
│ │ └── project.pbxproj
│ └── Target Support Files
│ │ ├── Pods-ZHPopupView_Example
│ │ ├── Info.plist
│ │ ├── Pods-ZHPopupView_Example-acknowledgements.markdown
│ │ ├── Pods-ZHPopupView_Example-acknowledgements.plist
│ │ ├── Pods-ZHPopupView_Example-dummy.m
│ │ ├── Pods-ZHPopupView_Example-frameworks.sh
│ │ ├── Pods-ZHPopupView_Example-resources.sh
│ │ ├── Pods-ZHPopupView_Example-umbrella.h
│ │ ├── Pods-ZHPopupView_Example.debug.xcconfig
│ │ ├── Pods-ZHPopupView_Example.modulemap
│ │ └── Pods-ZHPopupView_Example.release.xcconfig
│ │ ├── Pods-ZHPopupView_Tests
│ │ ├── Info.plist
│ │ ├── Pods-ZHPopupView_Tests-acknowledgements.markdown
│ │ ├── Pods-ZHPopupView_Tests-acknowledgements.plist
│ │ ├── Pods-ZHPopupView_Tests-dummy.m
│ │ ├── Pods-ZHPopupView_Tests-frameworks.sh
│ │ ├── Pods-ZHPopupView_Tests-resources.sh
│ │ ├── Pods-ZHPopupView_Tests-umbrella.h
│ │ ├── Pods-ZHPopupView_Tests.debug.xcconfig
│ │ ├── Pods-ZHPopupView_Tests.modulemap
│ │ └── Pods-ZHPopupView_Tests.release.xcconfig
│ │ └── ZHPopupView
│ │ ├── Info.plist
│ │ ├── ZHPopupView-dummy.m
│ │ ├── ZHPopupView-prefix.pch
│ │ ├── ZHPopupView-umbrella.h
│ │ ├── ZHPopupView.modulemap
│ │ └── ZHPopupView.xcconfig
├── Tests
│ ├── Tests-Info.plist
│ ├── Tests-Prefix.pch
│ ├── Tests.m
│ └── en.lproj
│ │ └── InfoPlist.strings
├── ZHPopupView.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── ZHPopupView-Example.xcscheme
├── ZHPopupView.xcworkspace
│ └── contents.xcworkspacedata
└── ZHPopupView
│ ├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── LaunchImage.launchimage
│ │ └── Contents.json
│ ├── Main.storyboard
│ ├── ZHPopupView-Info.plist
│ ├── ZHPopupView-Prefix.pch
│ ├── ZHPopupViewAppDelegate.h
│ ├── ZHPopupViewAppDelegate.m
│ ├── ZHPopupViewViewController.h
│ ├── ZHPopupViewViewController.m
│ ├── en.lproj
│ └── InfoPlist.strings
│ └── main.m
├── LICENSE
├── README.md
├── ZHPopupView.podspec
├── ZHPopupView.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ └── contents.xcworkspacedata
├── ZHPopupView
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Contents.json
│ └── correct_icon.imageset
│ │ ├── Contents.json
│ │ ├── correct_icon@2x.png
│ │ └── correct_icon@3x.png
├── Assets
│ └── .gitkeep
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Classes
│ ├── .gitkeep
│ └── ZHPopupView
│ │ ├── UIColor+HexString.h
│ │ ├── UIColor+HexString.m
│ │ ├── UIImageEffects.h
│ │ ├── UIImageEffects.m
│ │ ├── UIView+DropShadow.h
│ │ ├── UIView+DropShadow.m
│ │ ├── ZHPopupView.h
│ │ └── ZHPopupView.m
├── Info.plist
├── ViewController.h
├── ViewController.m
├── ZHPopupView
│ ├── UIColor+HexString.h
│ ├── UIColor+HexString.m
│ ├── UIImageEffects.h
│ ├── UIImageEffects.m
│ ├── UIView+DropShadow.h
│ ├── UIView+DropShadow.m
│ ├── ZHPopupView.h
│ └── ZHPopupView.m
├── comic-sans.ttf
└── main.m
├── _Pods.xcodeproj
└── screen.png
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # OS X
3 | .DS_Store
4 |
5 | # Xcode
6 | build/
7 |
8 | # Xcode
9 | #
10 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
11 |
12 | ## Build generated
13 | build/
14 | DerivedData
15 |
16 | ## Various settings
17 | *.pbxuser
18 | !default.pbxuser
19 | *.mode1v3
20 | !default.mode1v3
21 | *.mode2v3
22 | !default.mode2v3
23 | *.perspectivev3
24 | !default.perspectivev3
25 |
26 |
27 | xcuserdata/
28 | *.xccheckout
29 | profile
30 | *.moved-aside
31 | DerivedData
32 | *.hmap
33 | *.ipa
34 |
35 | # Bundler
36 | .bundle
37 |
38 | Carthage
39 | # We recommend against adding the Pods directory to your .gitignore. However
40 | # you should judge for yourself, the pros and cons are mentioned at:
41 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
42 | #
43 | # Note: if you ignore the Pods directory, make sure to uncomment
44 | # `pod install` in .travis.yml
45 | #
46 | # Pods/
47 | xcuserdata
48 |
49 | ## Other
50 | *.xccheckout
51 | *.moved-aside
52 | *.xcuserstate
53 | *.xcscmblueprint
54 |
55 | ## Obj-C/Swift specific
56 | *.hmap
57 | *.ipa
58 |
59 | # CocoaPods
60 | #
61 | # We recommend against adding the Pods directory to your .gitignore. However
62 | # you should judge for yourself, the pros and cons are mentioned at:
63 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
64 | #
65 | # Pods/
66 |
67 | # Carthage
68 | #
69 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
70 | # Carthage/Checkouts
71 |
72 | Carthage/Build
73 |
74 | # fastlane
75 | #
76 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
77 | # screenshots whenever they are needed.
78 | # For more information about the recommended setup visit:
79 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
80 |
81 | fastlane/report.xml
82 | fastlane/screenshots
83 | .idea/encodings.xml
84 | .idea/modules.xml
85 | .idea/vcs.xml
86 | .idea/workspace.xml
87 | .idea/xcode.xml
88 | .idea/ZHPopupView.iml
89 | .idea/.name
90 | .idea/misc.xml
91 | Example/.idea/.name
92 | Example/.idea/encodings.xml
93 | Example/.idea/Example.iml
94 | Example/.idea/misc.xml
95 | Example/.idea/modules.xml
96 | Example/.idea/workspace.xml
97 | Example/.idea/xcode.xml
98 | Example/.idea/runConfigurations/ZHPopupView_Example.xml
99 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # references:
2 | # * http://www.objc.io/issue-6/travis-ci.html
3 | # * https://github.com/supermarin/xcpretty#usage
4 |
5 | language: objective-c
6 | # cache: cocoapods
7 | # podfile: Example/Podfile
8 | # before_install:
9 | # - gem install cocoapods # Since Travis is not always on latest version
10 | # - pod install --project-directory=Example
11 | script:
12 | - set -o pipefail && xcodebuild test -workspace Example/ZHPopupView.xcworkspace -scheme ZHPopupView-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty
13 | - pod lib lint
14 |
--------------------------------------------------------------------------------
/Example/Podfile:
--------------------------------------------------------------------------------
1 | use_frameworks!
2 |
3 | target 'ZHPopupView_Example' do
4 | pod 'ZHPopupView', :path => '../'
5 |
6 | target 'ZHPopupView_Tests' do
7 | inherit! :search_paths
8 |
9 |
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/Example/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - ZHPopupView (0.1.0)
3 |
4 | DEPENDENCIES:
5 | - ZHPopupView (from `../`)
6 |
7 | EXTERNAL SOURCES:
8 | ZHPopupView:
9 | :path: ../
10 |
11 | SPEC CHECKSUMS:
12 | ZHPopupView: a6922951d4ecb74b892526163f71b1b2c80a04ed
13 |
14 | PODFILE CHECKSUM: 9652c77ce39b6da427b02414d6654819a56edddd
15 |
16 | COCOAPODS: 1.0.0
17 |
--------------------------------------------------------------------------------
/Example/Pods/Local Podspecs/ZHPopupView.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ZHPopupView",
3 | "version": "0.1.0",
4 | "summary": "A simple iOS Pop up View to display alert or dialog",
5 | "description": "Simple iOS Pop up View to display alert or dialog, with blur/normal fade in display mode",
6 | "homepage": "https://github.com/zhhlmr/ZHPopupView",
7 | "license": "MIT",
8 | "authors": {
9 | "zhhlmr": "zhouhan199132@gmail.com"
10 | },
11 | "source": {
12 | "git": "https://github.com/zhhlmr/ZHPopupView.git",
13 | "tag": "0.1.0"
14 | },
15 | "platforms": {
16 | "ios": "8.0"
17 | },
18 | "source_files": "ZHPopupView/Classes/**/*"
19 | }
20 |
--------------------------------------------------------------------------------
/Example/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - ZHPopupView (0.1.0)
3 |
4 | DEPENDENCIES:
5 | - ZHPopupView (from `../`)
6 |
7 | EXTERNAL SOURCES:
8 | ZHPopupView:
9 | :path: ../
10 |
11 | SPEC CHECKSUMS:
12 | ZHPopupView: a6922951d4ecb74b892526163f71b1b2c80a04ed
13 |
14 | PODFILE CHECKSUM: 9652c77ce39b6da427b02414d6654819a56edddd
15 |
16 | COCOAPODS: 1.0.0
17 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/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.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## ZHPopupView
5 |
6 | Copyright (c) 2016 zhhlmr
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in
16 | all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 | Generated by CocoaPods - https://cocoapods.org
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Copyright (c) 2016 zhhlmr <zhouhan199132@gmail.com>
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 | Title
38 | ZHPopupView
39 | Type
40 | PSGroupSpecifier
41 |
42 |
43 | FooterText
44 | Generated by CocoaPods - https://cocoapods.org
45 | Title
46 |
47 | Type
48 | PSGroupSpecifier
49 |
50 |
51 | StringsTable
52 | Acknowledgements
53 | Title
54 | Acknowledgements
55 |
56 |
57 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_ZHPopupView_Example : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_ZHPopupView_Example
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
6 |
7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
8 |
9 | install_framework()
10 | {
11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
12 | local source="${BUILT_PRODUCTS_DIR}/$1"
13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
15 | elif [ -r "$1" ]; then
16 | local source="$1"
17 | fi
18 |
19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
20 |
21 | if [ -L "${source}" ]; then
22 | echo "Symlinked..."
23 | source="$(readlink "${source}")"
24 | fi
25 |
26 | # use filter instead of exclude so missing patterns dont' throw errors
27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
29 |
30 | local basename
31 | basename="$(basename -s .framework "$1")"
32 | binary="${destination}/${basename}.framework/${basename}"
33 | if ! [ -r "$binary" ]; then
34 | binary="${destination}/${basename}"
35 | fi
36 |
37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
39 | strip_invalid_archs "$binary"
40 | fi
41 |
42 | # Resign the code if required by the build settings to avoid unstable apps
43 | code_sign_if_enabled "${destination}/$(basename "$1")"
44 |
45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
47 | local swift_runtime_libs
48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
49 | for lib in $swift_runtime_libs; do
50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
52 | code_sign_if_enabled "${destination}/${lib}"
53 | done
54 | fi
55 | }
56 |
57 | # Signs a framework with the provided identity
58 | code_sign_if_enabled() {
59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
60 | # Use the current code_sign_identitiy
61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\""
63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"
64 | fi
65 | }
66 |
67 | # Strip invalid architectures
68 | strip_invalid_archs() {
69 | binary="$1"
70 | # Get architectures for current file
71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
72 | stripped=""
73 | for arch in $archs; do
74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
75 | # Strip non-valid architectures in-place
76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
77 | stripped="$stripped $arch"
78 | fi
79 | done
80 | if [[ "$stripped" ]]; then
81 | echo "Stripped $binary of architectures:$stripped"
82 | fi
83 | }
84 |
85 |
86 | if [[ "$CONFIGURATION" == "Debug" ]]; then
87 | install_framework "$BUILT_PRODUCTS_DIR/ZHPopupView/ZHPopupView.framework"
88 | fi
89 | if [[ "$CONFIGURATION" == "Release" ]]; then
90 | install_framework "$BUILT_PRODUCTS_DIR/ZHPopupView/ZHPopupView.framework"
91 | fi
92 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
5 |
6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
7 | > "$RESOURCES_TO_COPY"
8 |
9 | XCASSET_FILES=()
10 |
11 | case "${TARGETED_DEVICE_FAMILY}" in
12 | 1,2)
13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
14 | ;;
15 | 1)
16 | TARGET_DEVICE_ARGS="--target-device iphone"
17 | ;;
18 | 2)
19 | TARGET_DEVICE_ARGS="--target-device ipad"
20 | ;;
21 | *)
22 | TARGET_DEVICE_ARGS="--target-device mac"
23 | ;;
24 | esac
25 |
26 | realpath() {
27 | DIRECTORY="$(cd "${1%/*}" && pwd)"
28 | FILENAME="${1##*/}"
29 | echo "$DIRECTORY/$FILENAME"
30 | }
31 |
32 | install_resource()
33 | {
34 | if [[ "$1" = /* ]] ; then
35 | RESOURCE_PATH="$1"
36 | else
37 | RESOURCE_PATH="${PODS_ROOT}/$1"
38 | fi
39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then
40 | cat << EOM
41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
42 | EOM
43 | exit 1
44 | fi
45 | case $RESOURCE_PATH in
46 | *.storyboard)
47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}"
48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
49 | ;;
50 | *.xib)
51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT}"
52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}"
53 | ;;
54 | *.framework)
55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
59 | ;;
60 | *.xcdatamodel)
61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\""
62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
63 | ;;
64 | *.xcdatamodeld)
65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\""
66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
67 | ;;
68 | *.xcmappingmodel)
69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\""
70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
71 | ;;
72 | *.xcassets)
73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH")
74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
75 | ;;
76 | *)
77 | echo "$RESOURCE_PATH"
78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
79 | ;;
80 | esac
81 | }
82 |
83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
88 | fi
89 | rm -f "$RESOURCES_TO_COPY"
90 |
91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
92 | then
93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
95 | while read line; do
96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
97 | XCASSET_FILES+=("$line")
98 | fi
99 | done <<<"$OTHER_XCASSETS"
100 |
101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
102 | fi
103 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example-umbrella.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 |
4 | FOUNDATION_EXPORT double Pods_ZHPopupView_ExampleVersionNumber;
5 | FOUNDATION_EXPORT const unsigned char Pods_ZHPopupView_ExampleVersionString[];
6 |
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example.debug.xcconfig:
--------------------------------------------------------------------------------
1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView"
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView/ZHPopupView.framework/Headers"
5 | OTHER_LDFLAGS = $(inherited) -framework "ZHPopupView"
6 | PODS_BUILD_DIR = $BUILD_DIR
7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_ROOT = ${SRCROOT}/Pods
9 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_ZHPopupView_Example {
2 | umbrella header "Pods-ZHPopupView_Example-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Example/Pods-ZHPopupView_Example.release.xcconfig:
--------------------------------------------------------------------------------
1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView"
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView/ZHPopupView.framework/Headers"
5 | OTHER_LDFLAGS = $(inherited) -framework "ZHPopupView"
6 | PODS_BUILD_DIR = $BUILD_DIR
7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 | PODS_ROOT = ${SRCROOT}/Pods
9 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/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.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 | Generated by CocoaPods - https://cocoapods.org
4 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Generated by CocoaPods - https://cocoapods.org
18 | Title
19 |
20 | Type
21 | PSGroupSpecifier
22 |
23 |
24 | StringsTable
25 | Acknowledgements
26 | Title
27 | Acknowledgements
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_ZHPopupView_Tests : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_ZHPopupView_Tests
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
6 |
7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
8 |
9 | install_framework()
10 | {
11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
12 | local source="${BUILT_PRODUCTS_DIR}/$1"
13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
15 | elif [ -r "$1" ]; then
16 | local source="$1"
17 | fi
18 |
19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
20 |
21 | if [ -L "${source}" ]; then
22 | echo "Symlinked..."
23 | source="$(readlink "${source}")"
24 | fi
25 |
26 | # use filter instead of exclude so missing patterns dont' throw errors
27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
29 |
30 | local basename
31 | basename="$(basename -s .framework "$1")"
32 | binary="${destination}/${basename}.framework/${basename}"
33 | if ! [ -r "$binary" ]; then
34 | binary="${destination}/${basename}"
35 | fi
36 |
37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
39 | strip_invalid_archs "$binary"
40 | fi
41 |
42 | # Resign the code if required by the build settings to avoid unstable apps
43 | code_sign_if_enabled "${destination}/$(basename "$1")"
44 |
45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
47 | local swift_runtime_libs
48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
49 | for lib in $swift_runtime_libs; do
50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
52 | code_sign_if_enabled "${destination}/${lib}"
53 | done
54 | fi
55 | }
56 |
57 | # Signs a framework with the provided identity
58 | code_sign_if_enabled() {
59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
60 | # Use the current code_sign_identitiy
61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\""
63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"
64 | fi
65 | }
66 |
67 | # Strip invalid architectures
68 | strip_invalid_archs() {
69 | binary="$1"
70 | # Get architectures for current file
71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
72 | stripped=""
73 | for arch in $archs; do
74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
75 | # Strip non-valid architectures in-place
76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
77 | stripped="$stripped $arch"
78 | fi
79 | done
80 | if [[ "$stripped" ]]; then
81 | echo "Stripped $binary of architectures:$stripped"
82 | fi
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
5 |
6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
7 | > "$RESOURCES_TO_COPY"
8 |
9 | XCASSET_FILES=()
10 |
11 | case "${TARGETED_DEVICE_FAMILY}" in
12 | 1,2)
13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
14 | ;;
15 | 1)
16 | TARGET_DEVICE_ARGS="--target-device iphone"
17 | ;;
18 | 2)
19 | TARGET_DEVICE_ARGS="--target-device ipad"
20 | ;;
21 | *)
22 | TARGET_DEVICE_ARGS="--target-device mac"
23 | ;;
24 | esac
25 |
26 | realpath() {
27 | DIRECTORY="$(cd "${1%/*}" && pwd)"
28 | FILENAME="${1##*/}"
29 | echo "$DIRECTORY/$FILENAME"
30 | }
31 |
32 | install_resource()
33 | {
34 | if [[ "$1" = /* ]] ; then
35 | RESOURCE_PATH="$1"
36 | else
37 | RESOURCE_PATH="${PODS_ROOT}/$1"
38 | fi
39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then
40 | cat << EOM
41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
42 | EOM
43 | exit 1
44 | fi
45 | case $RESOURCE_PATH in
46 | *.storyboard)
47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}"
48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
49 | ;;
50 | *.xib)
51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT}"
52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}"
53 | ;;
54 | *.framework)
55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
59 | ;;
60 | *.xcdatamodel)
61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\""
62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
63 | ;;
64 | *.xcdatamodeld)
65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\""
66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
67 | ;;
68 | *.xcmappingmodel)
69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\""
70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
71 | ;;
72 | *.xcassets)
73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH")
74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
75 | ;;
76 | *)
77 | echo "$RESOURCE_PATH"
78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
79 | ;;
80 | esac
81 | }
82 |
83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
88 | fi
89 | rm -f "$RESOURCES_TO_COPY"
90 |
91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
92 | then
93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
95 | while read line; do
96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
97 | XCASSET_FILES+=("$line")
98 | fi
99 | done <<<"$OTHER_XCASSETS"
100 |
101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
102 | fi
103 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests-umbrella.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 |
4 | FOUNDATION_EXPORT double Pods_ZHPopupView_TestsVersionNumber;
5 | FOUNDATION_EXPORT const unsigned char Pods_ZHPopupView_TestsVersionString[];
6 |
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests.debug.xcconfig:
--------------------------------------------------------------------------------
1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView"
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView/ZHPopupView.framework/Headers"
5 | PODS_BUILD_DIR = $BUILD_DIR
6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 | PODS_ROOT = ${SRCROOT}/Pods
8 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests.modulemap:
--------------------------------------------------------------------------------
1 | framework module Pods_ZHPopupView_Tests {
2 | umbrella header "Pods-ZHPopupView_Tests-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/Pods-ZHPopupView_Tests/Pods-ZHPopupView_Tests.release.xcconfig:
--------------------------------------------------------------------------------
1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView"
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ZHPopupView/ZHPopupView.framework/Headers"
5 | PODS_BUILD_DIR = $BUILD_DIR
6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 | PODS_ROOT = ${SRCROOT}/Pods
8 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/ZHPopupView/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 | 0.1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${CURRENT_PROJECT_VERSION}
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/ZHPopupView/ZHPopupView-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_ZHPopupView : NSObject
3 | @end
4 | @implementation PodsDummy_ZHPopupView
5 | @end
6 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/ZHPopupView/ZHPopupView-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/ZHPopupView/ZHPopupView-umbrella.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "UIColor+HexString.h"
4 | #import "UIImageEffects.h"
5 | #import "UIView+DropShadow.h"
6 | #import "ZHPopupView.h"
7 |
8 | FOUNDATION_EXPORT double ZHPopupViewVersionNumber;
9 | FOUNDATION_EXPORT const unsigned char ZHPopupViewVersionString[];
10 |
11 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/ZHPopupView/ZHPopupView.modulemap:
--------------------------------------------------------------------------------
1 | framework module ZHPopupView {
2 | umbrella header "ZHPopupView-umbrella.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Pods/Target Support Files/ZHPopupView/ZHPopupView.xcconfig:
--------------------------------------------------------------------------------
1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/ZHPopupView
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public"
4 | PODS_BUILD_DIR = $BUILD_DIR
5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
6 | PODS_ROOT = ${SRCROOT}
7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
8 | SKIP_INSTALL = YES
9 |
--------------------------------------------------------------------------------
/Example/Tests/Tests-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 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Example/Tests/Tests-Prefix.pch:
--------------------------------------------------------------------------------
1 | // The contents of this file are implicitly included at the beginning of every test case source file.
2 |
3 | #ifdef __OBJC__
4 |
5 |
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/Example/Tests/Tests.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupViewTests.m
3 | // ZHPopupViewTests
4 | //
5 | // Created by zhhlmr on 05/19/2016.
6 | // Copyright (c) 2016 zhhlmr. All rights reserved.
7 | //
8 |
9 | @import XCTest;
10 |
11 | @interface Tests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation Tests
16 |
17 | - (void)setUp
18 | {
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 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
36 |
--------------------------------------------------------------------------------
/Example/Tests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Example/ZHPopupView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/ZHPopupView.xcodeproj/xcshareddata/xcschemes/ZHPopupView-Example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
66 |
72 |
73 |
74 |
75 |
76 |
77 |
83 |
85 |
91 |
92 |
93 |
94 |
96 |
97 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/Example/ZHPopupView.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "ipad",
20 | "size" : "29x29",
21 | "scale" : "1x"
22 | },
23 | {
24 | "idiom" : "ipad",
25 | "size" : "29x29",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "ipad",
30 | "size" : "40x40",
31 | "scale" : "1x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "40x40",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "76x76",
41 | "scale" : "1x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "76x76",
46 | "scale" : "2x"
47 | }
48 | ],
49 | "info" : {
50 | "version" : 1,
51 | "author" : "xcode"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | },
18 | {
19 | "orientation" : "portrait",
20 | "idiom" : "ipad",
21 | "extent" : "full-screen",
22 | "minimum-system-version" : "7.0",
23 | "scale" : "1x"
24 | },
25 | {
26 | "orientation" : "landscape",
27 | "idiom" : "ipad",
28 | "extent" : "full-screen",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "1x"
31 | },
32 | {
33 | "orientation" : "portrait",
34 | "idiom" : "ipad",
35 | "extent" : "full-screen",
36 | "minimum-system-version" : "7.0",
37 | "scale" : "2x"
38 | },
39 | {
40 | "orientation" : "landscape",
41 | "idiom" : "ipad",
42 | "extent" : "full-screen",
43 | "minimum-system-version" : "7.0",
44 | "scale" : "2x"
45 | }
46 | ],
47 | "info" : {
48 | "version" : 1,
49 | "author" : "xcode"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
27 |
34 |
41 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/ZHPopupView-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/ZHPopupView-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_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | @import UIKit;
15 | @import Foundation;
16 | #endif
17 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/ZHPopupViewAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupViewAppDelegate.h
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 05/19/2016.
6 | // Copyright (c) 2016 zhhlmr. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface ZHPopupViewAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/ZHPopupViewAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupViewAppDelegate.m
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 05/19/2016.
6 | // Copyright (c) 2016 zhhlmr. All rights reserved.
7 | //
8 |
9 | #import "ZHPopupViewAppDelegate.h"
10 |
11 | @implementation ZHPopupViewAppDelegate
12 |
13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14 | {
15 | // Override point for customization after application launch.
16 | return YES;
17 | }
18 |
19 | - (void)applicationWillResignActive:(UIApplication *)application
20 | {
21 | // 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.
22 | // 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.
23 | }
24 |
25 | - (void)applicationDidEnterBackground:(UIApplication *)application
26 | {
27 | // 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.
28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29 | }
30 |
31 | - (void)applicationWillEnterForeground:(UIApplication *)application
32 | {
33 | // 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.
34 | }
35 |
36 | - (void)applicationDidBecomeActive:(UIApplication *)application
37 | {
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 | {
43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/ZHPopupViewViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupViewViewController.h
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 05/19/2016.
6 | // Copyright (c) 2016 zhhlmr. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 |
11 | @interface ZHPopupViewViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/ZHPopupViewViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupViewViewController.m
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 05/19/2016.
6 | // Copyright (c) 2016 zhhlmr. All rights reserved.
7 | //
8 |
9 | #import "ZHPopupViewViewController.h"
10 | #import "ZHPopupView.h"
11 |
12 |
13 | #define kRandomText @"\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\""
14 |
15 | @interface ZHPopupViewViewController ()
16 |
17 | @end
18 |
19 | @implementation ZHPopupViewViewController
20 |
21 | - (void)viewDidLoad
22 | {
23 | [super viewDidLoad];
24 |
25 | }
26 |
27 | - (void)didReceiveMemoryWarning
28 | {
29 | [super didReceiveMemoryWarning];
30 | // Dispose of any resources that can be recreated.
31 | }
32 |
33 |
34 | #pragma mark - Pressed Events
35 |
36 | - (IBAction)pressedOnAlertViewPopup:(id)sender {
37 |
38 | ZHPopupView *popupView = [ZHPopupView popupNomralAlertViewInView:nil
39 | backgroundStyle:ZHPopupViewBackgroundType_SimpleOpacity
40 | title:@"Tips"
41 | content:@"Confirm to delete/remove?"
42 | buttonTitles:@[@"Cancel", @"Confirm"]
43 | confirmBtnTextColor:nil otherBtnTextColor:nil
44 | buttonPressedBlock:^(NSInteger btnIdx) {
45 |
46 |
47 | }];
48 |
49 | [popupView setContentTextAlignment:NSTextAlignmentCenter];
50 | [popupView present];
51 |
52 | }
53 |
54 | - (IBAction)pressedOnDialogViewPopup:(id)sender {
55 |
56 |
57 | ZHPopupView *popupView = [ZHPopupView popUpDialogViewInView:nil
58 | iconImg:[UIImage imageNamed:@"correct_icon"]
59 | backgroundStyle:ZHPopupViewBackgroundType_SimpleOpacity
60 | title:@"Lorem Ipsum"
61 | content:kRandomText
62 | buttonTitles:@[@"Cancel", @"Confirm"]
63 | confirmBtnTextColor:nil otherBtnTextColor:nil
64 | buttonPressedBlock:^(NSInteger btnIdx) {
65 |
66 |
67 | }];
68 | [popupView present];
69 |
70 |
71 | }
72 |
73 | - (IBAction)pressedOnBlurAlertViewPopup:(id)sender {
74 |
75 | ZHPopupView *popupView = [ZHPopupView popupNomralAlertViewInView:nil
76 | backgroundStyle:ZHPopupViewBackgroundType_Blur
77 | title:@"Tips"
78 | content:@"Confirm to delete/remove?"
79 | buttonTitles:@[@"Cancel", @"Confirm"]
80 | confirmBtnTextColor:nil otherBtnTextColor:nil
81 | buttonPressedBlock:^(NSInteger btnIdx) {
82 |
83 |
84 | }];
85 | [popupView present];
86 |
87 |
88 | }
89 |
90 | - (IBAction)pressedOnBlurDialogViewPopup:(id)sender {
91 | ZHPopupView *popupView = [ZHPopupView popUpDialogViewInView:nil
92 | iconImg:[UIImage imageNamed:@"correct_icon"]
93 | backgroundStyle:ZHPopupViewBackgroundType_Blur
94 | title:@"Lorem Ipsum"
95 | content:kRandomText
96 | buttonTitles:@[@"Cancel", @"Confirm"]
97 | confirmBtnTextColor:nil otherBtnTextColor:nil
98 | buttonPressedBlock:^(NSInteger btnIdx) {
99 |
100 |
101 | }];
102 | [popupView present];
103 | }
104 |
105 |
106 |
107 | @end
108 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Example/ZHPopupView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 05/19/2016.
6 | // Copyright (c) 2016 zhhlmr. All rights reserved.
7 | //
8 |
9 | @import UIKit;
10 | #import "ZHPopupViewAppDelegate.h"
11 |
12 | int main(int argc, char * argv[])
13 | {
14 | @autoreleasepool {
15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([ZHPopupViewAppDelegate class]));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 zhhlmr
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 | # ZHPopupView
2 |
3 |
4 | [](https://travis-ci.org/zhhlmr/ZHPopupView)
5 | [](http://cocoapods.org/pods/ZHPopupView)
6 | [](http://cocoapods.org/pods/ZHPopupView)
7 | [](http://cocoapods.org/pods/ZHPopupView)
8 |
9 |
10 | A simple iOS Pop up View to display alert or dialog
11 |
12 |
13 | 
14 |
15 |
16 |
17 | ### Usage
18 |
19 |
20 | ###### Alert View
21 |
22 | ```
23 | ZHPopupView *popupView = [ZHPopupView popupNormalAlertViewInView:nil
24 | backgroundStyle:ZHPopupViewBackgroundType_SimpleOpacity
25 | title:@"Tips"
26 | content:@"Confirm to delete/remove?"
27 | buttonTitles:@[@"Cancel", @"Confirm"]
28 | confirmBtnTextColor:nil otherBtnTextColor:nil
29 | buttonPressedBlock:^(NSInteger btnIdx) {
30 |
31 |
32 | }];
33 | [popupView present];
34 | ```
35 |
36 | ###### Dialog View
37 |
38 | ```
39 | ZHPopupView *popupView = [ZHPopupView popUpDialogViewInView:nil
40 | iconImg:[UIImage imageNamed:@"correct_icon"]
41 | backgroundStyle:ZHPopupViewBackgroundType_SimpleOpacity
42 | title:@"Lorem Ipsum"
43 | content:kRandomText
44 | buttonTitles:@[@"Cancel", @"Confirm"]
45 | confirmBtnTextColor:nil otherBtnTextColor:nil
46 | buttonPressedBlock:^(NSInteger btnIdx) {
47 |
48 |
49 | }];
50 | [popupView present];
51 |
52 | ```
53 |
54 |
55 | ### Properties
56 |
57 | ```
58 | @property(nonatomic, strong) NSString *headTitle;// Title string
59 | @property(nonatomic, strong) NSString *content; // Content String
60 | @property(nonatomic, strong) UIImage *headIconImg; // head Icon Img
61 |
62 | @property(nonatomic, strong) UIColor *headTitleColor; // Title Color
63 | @property(nonatomic, strong) UIColor *contentTextColor; // Content Text Color
64 |
65 | @property(nonatomic, assign) CGFloat headTitleFontSize;// Title font size
66 | @property(nonatomic, assign) CGFloat contentTextFontSize;// Content font size
67 |
68 | @property(nonatomic, assign) NSTextAlignment contentTextAlignment;// Content text Alignment
69 | @property(nonatomic, assign) NSTextAlignment headTextAlignment; // Title Text Alignment
70 |
71 |
72 |
73 | ```
74 |
75 | ### Callback
76 |
77 | ```
78 |
79 | @property(nonatomic, copy) void (^buttonPressedBlock)(NSInteger btnIdx); // Button Click/Pressed callback
80 | ```
81 |
82 | ### Background Display Type
83 |
84 |
85 | ```
86 |
87 | typedef enum {
88 |
89 | ZHPopupViewBackgroundType_SimpleOpacity = 0, // Default
90 | ZHPopupViewBackgroundType_Blur = 1 // With Radius 10.0f , will adding setting property about blur effect
91 |
92 | } ZHPopupViewBackgroundType;
93 |
94 | ```
95 |
96 | ## Example
97 |
98 | To run the example project, clone the repo, and run `pod install` from the Example directory first.
99 |
100 | ## Requirements
101 |
102 | ## Installation
103 |
104 | ZHPopupView is available through [CocoaPods](http://cocoapods.org). To install
105 | it, simply add the following line to your Podfile:
106 |
107 | ```ruby
108 | pod "ZHPopupView"
109 | ```
110 |
111 | ## Author
112 |
113 | [zhhlmr](https://github.com/zhhlmr), zhouhan199132@gmail.com
114 |
115 | ## License
116 |
117 | ZHPopupView is available under the MIT license. See the LICENSE file for more info.
118 |
--------------------------------------------------------------------------------
/ZHPopupView.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod lib lint ZHPopupView.podspec' to ensure this is a
3 | # valid spec before submitting.
4 | #
5 | # Any lines starting with a # are optional, but their use is encouraged
6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
7 | #
8 |
9 | Pod::Spec.new do |s|
10 | s.name = "ZHPopupView"
11 | s.version = "0.1.1"
12 | s.summary = "A simple iOS Pop up View to display alert or dialog"
13 |
14 | # This description is used to generate tags and improve search results.
15 | # * Think: What does it do? Why did you write it? What is the focus?
16 | # * Try to keep it short, snappy and to the point.
17 | # * Write the description between the DESC delimiters below.
18 | # * Finally, don't worry about the indent, CocoaPods strips it!
19 |
20 | s.description = "Simple iOS Pop up View to display alert or dialog, with blur/normal fade in display mode"
21 |
22 | s.homepage = "https://github.com/zhhlmr/ZHPopupView"
23 | # s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
24 | s.license = 'MIT'
25 | s.author = { "zhhlmr" => "zhouhan199132@gmail.com" }
26 | s.source = { :git => "https://github.com/zhhlmr/ZHPopupView.git", :tag => s.version.to_s }
27 | # s.social_media_url = 'https://twitter.com/'
28 |
29 | s.ios.deployment_target = '8.0'
30 |
31 | s.source_files = 'ZHPopupView/Classes/**/*'
32 |
33 | # s.resource_bundles = {
34 | # 'ZHPopupView' => ['ZHPopupView/Assets/*.png']
35 | # }
36 |
37 | # s.public_header_files = 'Pod/Classes/**/*.h'
38 | # s.frameworks = 'UIKit', 'MapKit'
39 | # s.dependency 'AFNetworking', '~> 2.3'
40 | end
41 |
--------------------------------------------------------------------------------
/ZHPopupView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 08DD3F841DF86AAE0099EC72 /* comic-sans.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 08DD3F831DF86AAE0099EC72 /* comic-sans.ttf */; };
11 | BA8BF3911CCF58C600D33062 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3901CCF58C600D33062 /* main.m */; };
12 | BA8BF3941CCF58C600D33062 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3931CCF58C600D33062 /* AppDelegate.m */; };
13 | BA8BF3971CCF58C600D33062 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3961CCF58C600D33062 /* ViewController.m */; };
14 | BA8BF39A1CCF58C600D33062 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BA8BF3981CCF58C600D33062 /* Main.storyboard */; };
15 | BA8BF39C1CCF58C600D33062 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA8BF39B1CCF58C600D33062 /* Assets.xcassets */; };
16 | BA8BF39F1CCF58C600D33062 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BA8BF39D1CCF58C600D33062 /* LaunchScreen.storyboard */; };
17 | BA8BF3AD1CCF58F000D33062 /* UIImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3A81CCF58F000D33062 /* UIImageEffects.m */; };
18 | BA8BF3AE1CCF58F000D33062 /* UIView+DropShadow.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3AA1CCF58F000D33062 /* UIView+DropShadow.m */; };
19 | BA8BF3AF1CCF58F000D33062 /* ZHPopupView.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3AC1CCF58F000D33062 /* ZHPopupView.m */; };
20 | BA8BF3B21CCF59F900D33062 /* UIColor+HexString.m in Sources */ = {isa = PBXBuildFile; fileRef = BA8BF3B11CCF59F900D33062 /* UIColor+HexString.m */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXFileReference section */
24 | 08DD3F831DF86AAE0099EC72 /* comic-sans.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "comic-sans.ttf"; sourceTree = ""; };
25 | BA8BF38C1CCF58C600D33062 /* ZHPopupView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZHPopupView.app; sourceTree = BUILT_PRODUCTS_DIR; };
26 | BA8BF3901CCF58C600D33062 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
27 | BA8BF3921CCF58C600D33062 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
28 | BA8BF3931CCF58C600D33062 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
29 | BA8BF3951CCF58C600D33062 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
30 | BA8BF3961CCF58C600D33062 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
31 | BA8BF3991CCF58C600D33062 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
32 | BA8BF39B1CCF58C600D33062 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
33 | BA8BF39E1CCF58C600D33062 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
34 | BA8BF3A01CCF58C600D33062 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
35 | BA8BF3A71CCF58F000D33062 /* UIImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIImageEffects.h; sourceTree = ""; };
36 | BA8BF3A81CCF58F000D33062 /* UIImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIImageEffects.m; sourceTree = ""; };
37 | BA8BF3A91CCF58F000D33062 /* UIView+DropShadow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+DropShadow.h"; sourceTree = ""; };
38 | BA8BF3AA1CCF58F000D33062 /* UIView+DropShadow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+DropShadow.m"; sourceTree = ""; };
39 | BA8BF3AB1CCF58F000D33062 /* ZHPopupView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZHPopupView.h; sourceTree = ""; };
40 | BA8BF3AC1CCF58F000D33062 /* ZHPopupView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZHPopupView.m; sourceTree = ""; };
41 | BA8BF3B01CCF59F900D33062 /* UIColor+HexString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+HexString.h"; sourceTree = ""; };
42 | BA8BF3B11CCF59F900D33062 /* UIColor+HexString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+HexString.m"; sourceTree = ""; };
43 | /* End PBXFileReference section */
44 |
45 | /* Begin PBXFrameworksBuildPhase section */
46 | BA8BF3891CCF58C600D33062 /* Frameworks */ = {
47 | isa = PBXFrameworksBuildPhase;
48 | buildActionMask = 2147483647;
49 | files = (
50 | );
51 | runOnlyForDeploymentPostprocessing = 0;
52 | };
53 | /* End PBXFrameworksBuildPhase section */
54 |
55 | /* Begin PBXGroup section */
56 | BA8BF3831CCF58C600D33062 = {
57 | isa = PBXGroup;
58 | children = (
59 | BA8BF38E1CCF58C600D33062 /* ZHPopupView */,
60 | BA8BF38D1CCF58C600D33062 /* Products */,
61 | );
62 | sourceTree = "";
63 | };
64 | BA8BF38D1CCF58C600D33062 /* Products */ = {
65 | isa = PBXGroup;
66 | children = (
67 | BA8BF38C1CCF58C600D33062 /* ZHPopupView.app */,
68 | );
69 | name = Products;
70 | sourceTree = "";
71 | };
72 | BA8BF38E1CCF58C600D33062 /* ZHPopupView */ = {
73 | isa = PBXGroup;
74 | children = (
75 | BA8BF3A61CCF58F000D33062 /* ZHPopupView */,
76 | BA8BF3921CCF58C600D33062 /* AppDelegate.h */,
77 | BA8BF3931CCF58C600D33062 /* AppDelegate.m */,
78 | BA8BF3951CCF58C600D33062 /* ViewController.h */,
79 | BA8BF3961CCF58C600D33062 /* ViewController.m */,
80 | BA8BF3981CCF58C600D33062 /* Main.storyboard */,
81 | BA8BF39B1CCF58C600D33062 /* Assets.xcassets */,
82 | BA8BF39D1CCF58C600D33062 /* LaunchScreen.storyboard */,
83 | BA8BF3A01CCF58C600D33062 /* Info.plist */,
84 | BA8BF38F1CCF58C600D33062 /* Supporting Files */,
85 | );
86 | path = ZHPopupView;
87 | sourceTree = "";
88 | };
89 | BA8BF38F1CCF58C600D33062 /* Supporting Files */ = {
90 | isa = PBXGroup;
91 | children = (
92 | 08DD3F831DF86AAE0099EC72 /* comic-sans.ttf */,
93 | BA8BF3901CCF58C600D33062 /* main.m */,
94 | );
95 | name = "Supporting Files";
96 | sourceTree = "";
97 | };
98 | BA8BF3A61CCF58F000D33062 /* ZHPopupView */ = {
99 | isa = PBXGroup;
100 | children = (
101 | BA8BF3A71CCF58F000D33062 /* UIImageEffects.h */,
102 | BA8BF3A81CCF58F000D33062 /* UIImageEffects.m */,
103 | BA8BF3A91CCF58F000D33062 /* UIView+DropShadow.h */,
104 | BA8BF3AA1CCF58F000D33062 /* UIView+DropShadow.m */,
105 | BA8BF3AB1CCF58F000D33062 /* ZHPopupView.h */,
106 | BA8BF3AC1CCF58F000D33062 /* ZHPopupView.m */,
107 | BA8BF3B01CCF59F900D33062 /* UIColor+HexString.h */,
108 | BA8BF3B11CCF59F900D33062 /* UIColor+HexString.m */,
109 | );
110 | path = ZHPopupView;
111 | sourceTree = "";
112 | };
113 | /* End PBXGroup section */
114 |
115 | /* Begin PBXNativeTarget section */
116 | BA8BF38B1CCF58C600D33062 /* ZHPopupView */ = {
117 | isa = PBXNativeTarget;
118 | buildConfigurationList = BA8BF3A31CCF58C600D33062 /* Build configuration list for PBXNativeTarget "ZHPopupView" */;
119 | buildPhases = (
120 | BA8BF3881CCF58C600D33062 /* Sources */,
121 | BA8BF3891CCF58C600D33062 /* Frameworks */,
122 | BA8BF38A1CCF58C600D33062 /* Resources */,
123 | );
124 | buildRules = (
125 | );
126 | dependencies = (
127 | );
128 | name = ZHPopupView;
129 | productName = ZHPopupView;
130 | productReference = BA8BF38C1CCF58C600D33062 /* ZHPopupView.app */;
131 | productType = "com.apple.product-type.application";
132 | };
133 | /* End PBXNativeTarget section */
134 |
135 | /* Begin PBXProject section */
136 | BA8BF3841CCF58C600D33062 /* Project object */ = {
137 | isa = PBXProject;
138 | attributes = {
139 | LastUpgradeCheck = 0730;
140 | ORGANIZATIONNAME = heyz3a;
141 | TargetAttributes = {
142 | BA8BF38B1CCF58C600D33062 = {
143 | CreatedOnToolsVersion = 7.3;
144 | };
145 | };
146 | };
147 | buildConfigurationList = BA8BF3871CCF58C600D33062 /* Build configuration list for PBXProject "ZHPopupView" */;
148 | compatibilityVersion = "Xcode 3.2";
149 | developmentRegion = English;
150 | hasScannedForEncodings = 0;
151 | knownRegions = (
152 | en,
153 | Base,
154 | );
155 | mainGroup = BA8BF3831CCF58C600D33062;
156 | productRefGroup = BA8BF38D1CCF58C600D33062 /* Products */;
157 | projectDirPath = "";
158 | projectRoot = "";
159 | targets = (
160 | BA8BF38B1CCF58C600D33062 /* ZHPopupView */,
161 | );
162 | };
163 | /* End PBXProject section */
164 |
165 | /* Begin PBXResourcesBuildPhase section */
166 | BA8BF38A1CCF58C600D33062 /* Resources */ = {
167 | isa = PBXResourcesBuildPhase;
168 | buildActionMask = 2147483647;
169 | files = (
170 | BA8BF39F1CCF58C600D33062 /* LaunchScreen.storyboard in Resources */,
171 | BA8BF39C1CCF58C600D33062 /* Assets.xcassets in Resources */,
172 | BA8BF39A1CCF58C600D33062 /* Main.storyboard in Resources */,
173 | 08DD3F841DF86AAE0099EC72 /* comic-sans.ttf in Resources */,
174 | );
175 | runOnlyForDeploymentPostprocessing = 0;
176 | };
177 | /* End PBXResourcesBuildPhase section */
178 |
179 | /* Begin PBXSourcesBuildPhase section */
180 | BA8BF3881CCF58C600D33062 /* Sources */ = {
181 | isa = PBXSourcesBuildPhase;
182 | buildActionMask = 2147483647;
183 | files = (
184 | BA8BF3AE1CCF58F000D33062 /* UIView+DropShadow.m in Sources */,
185 | BA8BF3AD1CCF58F000D33062 /* UIImageEffects.m in Sources */,
186 | BA8BF3971CCF58C600D33062 /* ViewController.m in Sources */,
187 | BA8BF3AF1CCF58F000D33062 /* ZHPopupView.m in Sources */,
188 | BA8BF3B21CCF59F900D33062 /* UIColor+HexString.m in Sources */,
189 | BA8BF3941CCF58C600D33062 /* AppDelegate.m in Sources */,
190 | BA8BF3911CCF58C600D33062 /* main.m in Sources */,
191 | );
192 | runOnlyForDeploymentPostprocessing = 0;
193 | };
194 | /* End PBXSourcesBuildPhase section */
195 |
196 | /* Begin PBXVariantGroup section */
197 | BA8BF3981CCF58C600D33062 /* Main.storyboard */ = {
198 | isa = PBXVariantGroup;
199 | children = (
200 | BA8BF3991CCF58C600D33062 /* Base */,
201 | );
202 | name = Main.storyboard;
203 | sourceTree = "";
204 | };
205 | BA8BF39D1CCF58C600D33062 /* LaunchScreen.storyboard */ = {
206 | isa = PBXVariantGroup;
207 | children = (
208 | BA8BF39E1CCF58C600D33062 /* Base */,
209 | );
210 | name = LaunchScreen.storyboard;
211 | sourceTree = "";
212 | };
213 | /* End PBXVariantGroup section */
214 |
215 | /* Begin XCBuildConfiguration section */
216 | BA8BF3A11CCF58C600D33062 /* Debug */ = {
217 | isa = XCBuildConfiguration;
218 | buildSettings = {
219 | ALWAYS_SEARCH_USER_PATHS = NO;
220 | CLANG_ANALYZER_NONNULL = YES;
221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
222 | CLANG_CXX_LIBRARY = "libc++";
223 | CLANG_ENABLE_MODULES = YES;
224 | CLANG_ENABLE_OBJC_ARC = YES;
225 | CLANG_WARN_BOOL_CONVERSION = YES;
226 | CLANG_WARN_CONSTANT_CONVERSION = YES;
227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
228 | CLANG_WARN_EMPTY_BODY = YES;
229 | CLANG_WARN_ENUM_CONVERSION = YES;
230 | CLANG_WARN_INT_CONVERSION = YES;
231 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
232 | CLANG_WARN_UNREACHABLE_CODE = YES;
233 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
234 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
235 | COPY_PHASE_STRIP = NO;
236 | DEBUG_INFORMATION_FORMAT = dwarf;
237 | ENABLE_STRICT_OBJC_MSGSEND = YES;
238 | ENABLE_TESTABILITY = YES;
239 | GCC_C_LANGUAGE_STANDARD = gnu99;
240 | GCC_DYNAMIC_NO_PIC = NO;
241 | GCC_NO_COMMON_BLOCKS = YES;
242 | GCC_OPTIMIZATION_LEVEL = 0;
243 | GCC_PREPROCESSOR_DEFINITIONS = (
244 | "DEBUG=1",
245 | "$(inherited)",
246 | );
247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
249 | GCC_WARN_UNDECLARED_SELECTOR = YES;
250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
251 | GCC_WARN_UNUSED_FUNCTION = YES;
252 | GCC_WARN_UNUSED_VARIABLE = YES;
253 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
254 | MTL_ENABLE_DEBUG_INFO = YES;
255 | ONLY_ACTIVE_ARCH = YES;
256 | SDKROOT = iphoneos;
257 | };
258 | name = Debug;
259 | };
260 | BA8BF3A21CCF58C600D33062 /* Release */ = {
261 | isa = XCBuildConfiguration;
262 | buildSettings = {
263 | ALWAYS_SEARCH_USER_PATHS = NO;
264 | CLANG_ANALYZER_NONNULL = YES;
265 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
266 | CLANG_CXX_LIBRARY = "libc++";
267 | CLANG_ENABLE_MODULES = YES;
268 | CLANG_ENABLE_OBJC_ARC = YES;
269 | CLANG_WARN_BOOL_CONVERSION = YES;
270 | CLANG_WARN_CONSTANT_CONVERSION = YES;
271 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
272 | CLANG_WARN_EMPTY_BODY = YES;
273 | CLANG_WARN_ENUM_CONVERSION = YES;
274 | CLANG_WARN_INT_CONVERSION = YES;
275 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
276 | CLANG_WARN_UNREACHABLE_CODE = YES;
277 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
278 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
279 | COPY_PHASE_STRIP = NO;
280 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
281 | ENABLE_NS_ASSERTIONS = NO;
282 | ENABLE_STRICT_OBJC_MSGSEND = YES;
283 | GCC_C_LANGUAGE_STANDARD = gnu99;
284 | GCC_NO_COMMON_BLOCKS = YES;
285 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
286 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
287 | GCC_WARN_UNDECLARED_SELECTOR = YES;
288 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
289 | GCC_WARN_UNUSED_FUNCTION = YES;
290 | GCC_WARN_UNUSED_VARIABLE = YES;
291 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
292 | MTL_ENABLE_DEBUG_INFO = NO;
293 | SDKROOT = iphoneos;
294 | VALIDATE_PRODUCT = YES;
295 | };
296 | name = Release;
297 | };
298 | BA8BF3A41CCF58C600D33062 /* Debug */ = {
299 | isa = XCBuildConfiguration;
300 | buildSettings = {
301 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
302 | INFOPLIST_FILE = ZHPopupView/Info.plist;
303 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
304 | PRODUCT_BUNDLE_IDENTIFIER = com.jumpc.ZHPopupView;
305 | PRODUCT_NAME = "$(TARGET_NAME)";
306 | };
307 | name = Debug;
308 | };
309 | BA8BF3A51CCF58C600D33062 /* Release */ = {
310 | isa = XCBuildConfiguration;
311 | buildSettings = {
312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
313 | INFOPLIST_FILE = ZHPopupView/Info.plist;
314 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
315 | PRODUCT_BUNDLE_IDENTIFIER = com.jumpc.ZHPopupView;
316 | PRODUCT_NAME = "$(TARGET_NAME)";
317 | };
318 | name = Release;
319 | };
320 | /* End XCBuildConfiguration section */
321 |
322 | /* Begin XCConfigurationList section */
323 | BA8BF3871CCF58C600D33062 /* Build configuration list for PBXProject "ZHPopupView" */ = {
324 | isa = XCConfigurationList;
325 | buildConfigurations = (
326 | BA8BF3A11CCF58C600D33062 /* Debug */,
327 | BA8BF3A21CCF58C600D33062 /* Release */,
328 | );
329 | defaultConfigurationIsVisible = 0;
330 | defaultConfigurationName = Release;
331 | };
332 | BA8BF3A31CCF58C600D33062 /* Build configuration list for PBXNativeTarget "ZHPopupView" */ = {
333 | isa = XCConfigurationList;
334 | buildConfigurations = (
335 | BA8BF3A41CCF58C600D33062 /* Debug */,
336 | BA8BF3A51CCF58C600D33062 /* Release */,
337 | );
338 | defaultConfigurationIsVisible = 0;
339 | defaultConfigurationName = Release;
340 | };
341 | /* End XCConfigurationList section */
342 | };
343 | rootObject = BA8BF3841CCF58C600D33062 /* Project object */;
344 | }
345 |
--------------------------------------------------------------------------------
/ZHPopupView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ZHPopupView/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. 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 |
--------------------------------------------------------------------------------
/ZHPopupView/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. 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 |
--------------------------------------------------------------------------------
/ZHPopupView/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/ZHPopupView/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/ZHPopupView/Assets.xcassets/correct_icon.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "correct_icon@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "correct_icon@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/ZHPopupView/Assets.xcassets/correct_icon.imageset/correct_icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhhlmr/ZHPopupView/694d445ec83d38914ae98db12c8ed21b90aac677/ZHPopupView/Assets.xcassets/correct_icon.imageset/correct_icon@2x.png
--------------------------------------------------------------------------------
/ZHPopupView/Assets.xcassets/correct_icon.imageset/correct_icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhhlmr/ZHPopupView/694d445ec83d38914ae98db12c8ed21b90aac677/ZHPopupView/Assets.xcassets/correct_icon.imageset/correct_icon@3x.png
--------------------------------------------------------------------------------
/ZHPopupView/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhhlmr/ZHPopupView/694d445ec83d38914ae98db12c8ed21b90aac677/ZHPopupView/Assets/.gitkeep
--------------------------------------------------------------------------------
/ZHPopupView/Base.lproj/LaunchScreen.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 |
--------------------------------------------------------------------------------
/ZHPopupView/Base.lproj/Main.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 |
32 |
39 |
46 |
53 |
60 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/ZHPopupView/Classes/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhhlmr/ZHPopupView/694d445ec83d38914ae98db12c8ed21b90aac677/ZHPopupView/Classes/.gitkeep
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/UIColor+HexString.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+HexString.h
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIColor (HexString)
12 | +(UIColor*)colorWithHexString:(NSString*)hex;
13 | @end
14 |
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/UIColor+HexString.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+HexString.m
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. All rights reserved.
7 | //
8 |
9 | #import "UIColor+HexString.h"
10 |
11 | @implementation UIColor (HexString)
12 |
13 |
14 | +(UIColor*)colorWithHexString:(NSString*)hex
15 | {
16 | NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
17 |
18 | // String should be 6 or 8 characters
19 | if ([cString length] < 6) return [UIColor grayColor];
20 |
21 | // strip 0X if it appears
22 | if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];
23 |
24 | if ([cString length] != 6) return [UIColor grayColor];
25 |
26 | // Separate into r, g, b substrings
27 | NSRange range;
28 | range.location = 0;
29 | range.length = 2;
30 | NSString *rString = [cString substringWithRange:range];
31 |
32 | range.location = 2;
33 | NSString *gString = [cString substringWithRange:range];
34 |
35 | range.location = 4;
36 | NSString *bString = [cString substringWithRange:range];
37 |
38 | // Scan values
39 | unsigned int r, g, b;
40 | [[NSScanner scannerWithString:rString] scanHexInt:&r];
41 | [[NSScanner scannerWithString:gString] scanHexInt:&g];
42 | [[NSScanner scannerWithString:bString] scanHexInt:&b];
43 |
44 | return [UIColor colorWithRed:((float) r / 255.0f)
45 | green:((float) g / 255.0f)
46 | blue:((float) b / 255.0f)
47 | alpha:1.0f];
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/UIImageEffects.h:
--------------------------------------------------------------------------------
1 | /*
2 | File: UIImageEffects.h
3 | Abstract: This class contains methods to apply blur and tint effects to an image.
4 | This is the code you’ll want to look out to find out how to use vImage to
5 | efficiently calculate a blur.
6 | Version: 1.1
7 |
8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
9 | Inc. ("Apple") in consideration of your agreement to the following
10 | terms, and your use, installation, modification or redistribution of
11 | this Apple software constitutes acceptance of these terms. If you do
12 | not agree with these terms, please do not use, install, modify or
13 | redistribute this Apple software.
14 |
15 | In consideration of your agreement to abide by the following terms, and
16 | subject to these terms, Apple grants you a personal, non-exclusive
17 | license, under Apple's copyrights in this original Apple software (the
18 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
19 | Software, with or without modifications, in source and/or binary forms;
20 | provided that if you redistribute the Apple Software in its entirety and
21 | without modifications, you must retain this notice and the following
22 | text and disclaimers in all such redistributions of the Apple Software.
23 | Neither the name, trademarks, service marks or logos of Apple Inc. may
24 | be used to endorse or promote products derived from the Apple Software
25 | without specific prior written permission from Apple. Except as
26 | expressly stated in this notice, no other rights or licenses, express or
27 | implied, are granted by Apple herein, including but not limited to any
28 | patent rights that may be infringed by your derivative works or by other
29 | works in which the Apple Software may be incorporated.
30 |
31 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
32 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
33 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
34 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
35 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
36 |
37 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
38 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
41 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
42 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
43 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
44 | POSSIBILITY OF SUCH DAMAGE.
45 |
46 | Copyright (C) 2014 Apple Inc. All Rights Reserved.
47 |
48 | */
49 |
50 | #import
51 | #import
52 | @interface UIImageEffects : NSObject
53 |
54 | + (UIImage*)imageByApplyingLightEffectToImage:(UIImage*)inputImage;
55 | + (UIImage*)imageByApplyingExtraLightEffectToImage:(UIImage*)inputImage;
56 | + (UIImage*)imageByApplyingDarkEffectToImage:(UIImage*)inputImage;
57 | + (UIImage*)imageByApplyingTintEffectWithColor:(UIColor *)tintColor toImage:(UIImage*)inputImage;
58 |
59 | //| ----------------------------------------------------------------------------
60 | //! Applies a blur, tint color, and saturation adjustment to @a inputImage,
61 | //! optionally within the area specified by @a maskImage.
62 | //!
63 | //! @param inputImage
64 | //! The source image. A modified copy of this image will be returned.
65 | //! @param blurRadius
66 | //! The radius of the blur in points.
67 | //! @param tintColor
68 | //! An optional UIColor object that is uniformly blended with the
69 | //! result of the blur and saturation operations. The alpha channel
70 | //! of this color determines how strong the tint is.
71 | //! @param saturationDeltaFactor
72 | //! A value of 1.0 produces no change in the resulting image. Values
73 | //! less than 1.0 will desaturation the resulting image while values
74 | //! greater than 1.0 will have the opposite effect.
75 | //! @param maskImage
76 | //! If specified, @a inputImage is only modified in the area(s) defined
77 | //! by this mask. This must be an image mask or it must meet the
78 | //! requirements of the mask parameter of CGContextClipToMask.
79 | + (UIImage*)imageByApplyingBlurToImage:(UIImage*)inputImage withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
80 |
81 | @end
82 |
83 |
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/UIImageEffects.m:
--------------------------------------------------------------------------------
1 | /*
2 | File: UIImageEffects.m
3 | Abstract: This class contains methods to apply blur and tint effects to an image.
4 | This is the code you’ll want to look out to find out how to use vImage to
5 | efficiently calculate a blur.
6 | Version: 1.1
7 |
8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
9 | Inc. ("Apple") in consideration of your agreement to the following
10 | terms, and your use, installation, modification or redistribution of
11 | this Apple software constitutes acceptance of these terms. If you do
12 | not agree with these terms, please do not use, install, modify or
13 | redistribute this Apple software.
14 |
15 | In consideration of your agreement to abide by the following terms, and
16 | subject to these terms, Apple grants you a personal, non-exclusive
17 | license, under Apple's copyrights in this original Apple software (the
18 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
19 | Software, with or without modifications, in source and/or binary forms;
20 | provided that if you redistribute the Apple Software in its entirety and
21 | without modifications, you must retain this notice and the following
22 | text and disclaimers in all such redistributions of the Apple Software.
23 | Neither the name, trademarks, service marks or logos of Apple Inc. may
24 | be used to endorse or promote products derived from the Apple Software
25 | without specific prior written permission from Apple. Except as
26 | expressly stated in this notice, no other rights or licenses, express or
27 | implied, are granted by Apple herein, including but not limited to any
28 | patent rights that may be infringed by your derivative works or by other
29 | works in which the Apple Software may be incorporated.
30 |
31 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
32 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
33 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
34 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
35 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
36 |
37 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
38 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
41 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
42 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
43 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
44 | POSSIBILITY OF SUCH DAMAGE.
45 |
46 | Copyright (C) 2014 Apple Inc. All Rights Reserved.
47 |
48 | */
49 |
50 | #import "UIImageEffects.h"
51 |
52 | @import Accelerate;
53 |
54 | @implementation UIImageEffects
55 |
56 | #pragma mark -
57 | #pragma mark - Effects
58 |
59 | //| ----------------------------------------------------------------------------
60 | + (UIImage *)imageByApplyingLightEffectToImage:(UIImage*)inputImage
61 | {
62 | UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3];
63 | return [self imageByApplyingBlurToImage:inputImage withRadius:60 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
64 | }
65 |
66 |
67 | //| ----------------------------------------------------------------------------
68 | + (UIImage *)imageByApplyingExtraLightEffectToImage:(UIImage*)inputImage
69 | {
70 | UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82];
71 | return [self imageByApplyingBlurToImage:inputImage withRadius:40 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
72 | }
73 |
74 |
75 | //| ----------------------------------------------------------------------------
76 | + (UIImage *)imageByApplyingDarkEffectToImage:(UIImage*)inputImage
77 | {
78 | UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73];
79 | return [self imageByApplyingBlurToImage:inputImage withRadius:40 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
80 | }
81 |
82 |
83 | //| ----------------------------------------------------------------------------
84 | + (UIImage *)imageByApplyingTintEffectWithColor:(UIColor *)tintColor toImage:(UIImage*)inputImage
85 | {
86 | const CGFloat EffectColorAlpha = 0.6;
87 | UIColor *effectColor = tintColor;
88 | size_t componentCount = CGColorGetNumberOfComponents(tintColor.CGColor);
89 | if (componentCount == 2) {
90 | CGFloat b;
91 | if ([tintColor getWhite:&b alpha:NULL]) {
92 | effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha];
93 | }
94 | }
95 | else {
96 | CGFloat r, g, b;
97 | if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) {
98 | effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha];
99 | }
100 | }
101 | return [self imageByApplyingBlurToImage:inputImage withRadius:20 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil];
102 | }
103 |
104 | #pragma mark -
105 | #pragma mark - Implementation
106 |
107 | //| ----------------------------------------------------------------------------
108 | + (UIImage*)imageByApplyingBlurToImage:(UIImage*)inputImage withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage
109 | {
110 | #define ENABLE_BLUR 1
111 | #define ENABLE_SATURATION_ADJUSTMENT 1
112 | #define ENABLE_TINT 1
113 |
114 | // Check pre-conditions.
115 | if (inputImage.size.width < 1 || inputImage.size.height < 1)
116 | {
117 | NSLog(@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", inputImage.size.width, inputImage.size.height, inputImage);
118 | return nil;
119 | }
120 | if (!inputImage.CGImage)
121 | {
122 | NSLog(@"*** error: inputImage must be backed by a CGImage: %@", inputImage);
123 | return nil;
124 | }
125 | if (maskImage && !maskImage.CGImage)
126 | {
127 | NSLog(@"*** error: effectMaskImage must be backed by a CGImage: %@", maskImage);
128 | return nil;
129 | }
130 |
131 | BOOL hasBlur = blurRadius > __FLT_EPSILON__;
132 | BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__;
133 |
134 | CGImageRef inputCGImage = inputImage.CGImage;
135 | CGFloat inputImageScale = inputImage.scale;
136 | CGBitmapInfo inputImageBitmapInfo = CGImageGetBitmapInfo(inputCGImage);
137 | CGImageAlphaInfo inputImageAlphaInfo = (inputImageBitmapInfo & kCGBitmapAlphaInfoMask);
138 |
139 | CGSize outputImageSizeInPoints = inputImage.size;
140 | CGRect outputImageRectInPoints = { CGPointZero, outputImageSizeInPoints };
141 |
142 | // Set up output context.
143 | BOOL useOpaqueContext;
144 | if (inputImageAlphaInfo == kCGImageAlphaNone || inputImageAlphaInfo == kCGImageAlphaNoneSkipLast || inputImageAlphaInfo == kCGImageAlphaNoneSkipFirst)
145 | useOpaqueContext = YES;
146 | else
147 | useOpaqueContext = NO;
148 | UIGraphicsBeginImageContextWithOptions(outputImageRectInPoints.size, useOpaqueContext, inputImageScale);
149 | CGContextRef outputContext = UIGraphicsGetCurrentContext();
150 | CGContextScaleCTM(outputContext, 1.0, -1.0);
151 | CGContextTranslateCTM(outputContext, 0, -outputImageRectInPoints.size.height);
152 |
153 | if (hasBlur || hasSaturationChange)
154 | {
155 | vImage_Buffer effectInBuffer;
156 | vImage_Buffer scratchBuffer1;
157 |
158 | vImage_Buffer *inputBuffer;
159 | vImage_Buffer *outputBuffer;
160 |
161 | vImage_CGImageFormat format = {
162 | .bitsPerComponent = 8,
163 | .bitsPerPixel = 32,
164 | .colorSpace = NULL,
165 | // (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little)
166 | // requests a BGRA buffer.
167 | .bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
168 | .version = 0,
169 | .decode = NULL,
170 | .renderingIntent = kCGRenderingIntentDefault
171 | };
172 |
173 | vImage_Error e = vImageBuffer_InitWithCGImage(&effectInBuffer, &format, NULL, inputImage.CGImage, kvImagePrintDiagnosticsToConsole);
174 | if (e != kvImageNoError)
175 | {
176 | NSLog(@"*** error: vImageBuffer_InitWithCGImage returned error code %zi for inputImage: %@", e, inputImage);
177 | UIGraphicsEndImageContext();
178 | return nil;
179 | }
180 |
181 | vImageBuffer_Init(&scratchBuffer1, effectInBuffer.height, effectInBuffer.width, format.bitsPerPixel, kvImageNoFlags);
182 | inputBuffer = &effectInBuffer;
183 | outputBuffer = &scratchBuffer1;
184 |
185 | #if ENABLE_BLUR
186 | if (hasBlur)
187 | {
188 | // A description of how to compute the box kernel width from the Gaussian
189 | // radius (aka standard deviation) appears in the SVG spec:
190 | // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
191 | //
192 | // For larger values of 's' (s >= 2.0), an approximation can be used: Three
193 | // successive box-blurs build a piece-wise quadratic convolution kernel, which
194 | // approximates the Gaussian kernel to within roughly 3%.
195 | //
196 | // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
197 | //
198 | // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
199 | //
200 | CGFloat inputRadius = blurRadius * inputImageScale;
201 | if (inputRadius - 2. < __FLT_EPSILON__)
202 | inputRadius = 2.;
203 | uint32_t radius = floor((inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5) / 2);
204 |
205 | radius |= 1; // force radius to be odd so that the three box-blur methodology works.
206 |
207 | NSInteger tempBufferSize = vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize | kvImageEdgeExtend);
208 | void *tempBuffer = malloc(tempBufferSize);
209 |
210 | vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
211 | vImageBoxConvolve_ARGB8888(outputBuffer, inputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
212 | vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
213 |
214 | free(tempBuffer);
215 |
216 | vImage_Buffer *temp = inputBuffer;
217 | inputBuffer = outputBuffer;
218 | outputBuffer = temp;
219 | }
220 | #endif
221 |
222 | #if ENABLE_SATURATION_ADJUSTMENT
223 | if (hasSaturationChange)
224 | {
225 | CGFloat s = saturationDeltaFactor;
226 | // These values appear in the W3C Filter Effects spec:
227 | // https://dvcs.w3.org/hg/FXTF/raw-file/default/filters/index.html#grayscaleEquivalent
228 | //
229 | CGFloat floatingPointSaturationMatrix[] = {
230 | 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
231 | 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
232 | 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
233 | 0, 0, 0, 1,
234 | };
235 | const int32_t divisor = 256;
236 | NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]);
237 | int16_t saturationMatrix[matrixSize];
238 | for (NSUInteger i = 0; i < matrixSize; ++i) {
239 | saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor);
240 | }
241 | vImageMatrixMultiply_ARGB8888(inputBuffer, outputBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
242 |
243 | vImage_Buffer *temp = inputBuffer;
244 | inputBuffer = outputBuffer;
245 | outputBuffer = temp;
246 | }
247 | #endif
248 |
249 | CGImageRef effectCGImage;
250 | if ( (effectCGImage = vImageCreateCGImageFromBuffer(inputBuffer, &format, &cleanupBuffer, NULL, kvImageNoAllocate, NULL)) == NULL ) {
251 | effectCGImage = vImageCreateCGImageFromBuffer(inputBuffer, &format, NULL, NULL, kvImageNoFlags, NULL);
252 | free(inputBuffer->data);
253 | }
254 | if (maskImage) {
255 | // Only need to draw the base image if the effect image will be masked.
256 | CGContextDrawImage(outputContext, outputImageRectInPoints, inputCGImage);
257 | }
258 |
259 | // draw effect image
260 | CGContextSaveGState(outputContext);
261 | if (maskImage)
262 | CGContextClipToMask(outputContext, outputImageRectInPoints, maskImage.CGImage);
263 | CGContextDrawImage(outputContext, outputImageRectInPoints, effectCGImage);
264 | CGContextRestoreGState(outputContext);
265 |
266 | // Cleanup
267 | CGImageRelease(effectCGImage);
268 | free(outputBuffer->data);
269 | }
270 | else
271 | {
272 | // draw base image
273 | CGContextDrawImage(outputContext, outputImageRectInPoints, inputCGImage);
274 | }
275 |
276 | #if ENABLE_TINT
277 | // Add in color tint.
278 | if (tintColor)
279 | {
280 | CGContextSaveGState(outputContext);
281 | CGContextSetFillColorWithColor(outputContext, tintColor.CGColor);
282 | CGContextFillRect(outputContext, outputImageRectInPoints);
283 | CGContextRestoreGState(outputContext);
284 | }
285 | #endif
286 |
287 | // Output image is ready.
288 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
289 | UIGraphicsEndImageContext();
290 |
291 | return outputImage;
292 | #undef ENABLE_BLUR
293 | #undef ENABLE_SATURATION_ADJUSTMENT
294 | #undef ENABLE_TINT
295 | }
296 |
297 |
298 | //| ----------------------------------------------------------------------------
299 | // Helper function to handle deferred cleanup of a buffer.
300 | //
301 | void cleanupBuffer(void *userData, void *buf_data)
302 | { free(buf_data); }
303 |
304 | @end
305 |
306 |
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/UIView+DropShadow.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by heyz3a on 16/4/25.
3 | // Copyright (c) 2016 heyz3a. All rights reserved.
4 | //
5 |
6 | #import
7 | #import
8 |
9 | @interface UIView (DropShadow)
10 |
11 | - (void)dropShadowWithShadowColor:(UIColor *)shadowColor offset:(CGSize)offset opacity:(CGFloat)opacity radius:(CGFloat)radius;
12 | @end
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/UIView+DropShadow.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by heyz3a on 16/4/25.
3 | // Copyright (c) 2016 heyz3a. All rights reserved.
4 | //
5 |
6 | #import "UIView+DropShadow.h"
7 |
8 |
9 | @implementation UIView (DropShadow)
10 | - (void)dropShadowWithShadowColor:(UIColor *)shadowColor offset:(CGSize)offset opacity:(CGFloat)opacity radius:(CGFloat)radius {
11 |
12 | // Creating shadow path for better performance
13 | CGMutablePathRef path = CGPathCreateMutable();
14 | CGPathAddRect(path, NULL, self.bounds);
15 | self.layer.shadowPath = path;
16 | CGPathCloseSubpath(path);
17 | CGPathRelease(path);
18 |
19 | self.layer.shadowColor = shadowColor.CGColor;
20 | self.layer.shadowOffset = offset;
21 | self.layer.shadowRadius = radius;
22 | self.layer.shadowOpacity = opacity;
23 |
24 | // Default clipsToBounds is YES, will clip off the shadow, so we disable it.
25 | self.clipsToBounds = NO;
26 | }
27 |
28 |
29 | @end
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/ZHPopupView.h:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupView.h
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 16/4/25.
6 | // Copyright © 2016年 zhhlmr. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | typedef enum {
13 | ZHPopupViewBackgroundType_SimpleOpacity = 0,
14 | ZHPopupViewBackgroundType_Blur = 1
15 |
16 | } ZHPopupViewBackgroundType;
17 |
18 | @interface ZHPopupView : UIView
19 |
20 |
21 | @property(nonatomic, strong) NSString *headTitle;// Title string
22 | @property(nonatomic, strong) NSString *content; // Content String
23 | @property(nonatomic, strong) UIImage *headIconImg; // head Icon Img
24 |
25 | @property(nonatomic, strong) UIColor *headTitleColor; // Title Color
26 | @property(nonatomic, strong) UIColor *contentTextColor; // Content Text Color
27 |
28 | @property(nonatomic, assign) CGFloat headTitleFontSize;// Title font size
29 | @property(nonatomic, assign) CGFloat contentTextFontSize;// Content font size
30 |
31 | @property(nonatomic, assign) NSTextAlignment contentTextAlignment;// Content text Alignment
32 | @property(nonatomic, assign) NSTextAlignment headTextAlignment; // Title Text Alignment
33 |
34 | @property(nonatomic, copy) void (^buttonPressedBlock)(NSInteger btnIdx); // Button Click/Pressed callback
35 |
36 | @property(nonatomic,copy) void (^viewDismissedBlock)(); // Dismissed from background callback
37 |
38 | + (instancetype)popupViewInView:(UIView *)view;
39 |
40 | + (instancetype)popupBlurViewInView:(UIView *)view;
41 |
42 | + (instancetype)popupViewOnKeyWindow;
43 |
44 | + (instancetype)popupBlurViewOnKeyWindow;
45 |
46 | + (instancetype)popupNormalAlertViewInView:(UIView *)view backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock;
47 |
48 | + (instancetype)popupNormalAlertViewInView:(UIView *)view backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock viewDismissedBlock:(void (^)())viewDismissedBlock;
49 |
50 | + (instancetype)popUpDialogViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock;
51 |
52 | + (instancetype)popUpDialogViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock viewDismissedBlock:(void (^)())viewDismissedBlock;
53 |
54 | - (void)configureButtonWithTitles:(NSArray *)titles confirmTitleColor:(UIColor *)confirmTitleColor otherTitleColor:(UIColor *)otherTitleColor;
55 |
56 | - (void)present;
57 |
58 | - (void)disappear;
59 | @end
60 |
--------------------------------------------------------------------------------
/ZHPopupView/Classes/ZHPopupView/ZHPopupView.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupView.m
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 16/4/25.
6 | // Copyright © 2016年 zhhlmr. All rights reserved.
7 | //
8 |
9 | #import "ZHPopupView.h"
10 | #import "UIView+DropShadow.h"
11 | #import "UIColor+HexString.h"
12 | #import "UIImageEffects.h"
13 |
14 | #define kZHPopupViewContainerLeftRightInterval 55.0f
15 | #define kZHPopupView_ScreenHeight [UIScreen mainScreen].bounds.size.height
16 | #define kZHPopupView_ScreenWidth [UIScreen mainScreen].bounds.size.width
17 | #define kZHPopupViewContainerDefaultHeight 243.0f
18 |
19 | #define kZHPopupView_HeadInterval 20.0f
20 | #define kZHPopupView_InsideLeftInterval 25.0f
21 |
22 | #define kZHPopupView_buttonDefaultHeight 40.0f
23 |
24 | #define COLOR_333333 [UIColor colorWithHexString:@"333333"]
25 | #define COLOR_MAINRED [UIColor colorWithHexString:@"e31919"]
26 | #define COLOR_MAINBLUE [UIColor colorWithHexString:@"1bb4df"]
27 | #define COLOR_E5E5E5 [UIColor colorWithHexString:@"e5e5e5"]
28 |
29 |
30 | @interface ZHPopupView () {
31 | }
32 |
33 | @property(nonatomic, strong) UIImageView *headIconImgView;
34 | @property(nonatomic, strong) UILabel *headTitleLbl;
35 |
36 | @property(nonatomic, strong) UITextView *contentTextView;
37 | @property(nonatomic, strong) UIView *container;
38 | @property(nonatomic, weak) UIView *parentView;
39 | @property(nonatomic, assign) ZHPopupViewBackgroundType backgroundType;
40 |
41 | @property(nonatomic, strong) UIView *buttonArea;
42 |
43 |
44 | @end
45 |
46 | @implementation ZHPopupView
47 |
48 |
49 | - (instancetype)initWithFrame:(CGRect)frame {
50 | self = [super initWithFrame:frame];
51 | if (self) {
52 | [self _initialization];
53 |
54 |
55 | }
56 | return self;
57 | }
58 |
59 | - (instancetype)initPopUpViewInView:(UIView *)view backgroundType:(ZHPopupViewBackgroundType)backgroundType {
60 | self.parentView = view;
61 | self.backgroundType = backgroundType;
62 | self = [super initWithFrame:view.bounds];
63 | if (self) {
64 | [self _initialization];
65 | }
66 | return self;
67 | }
68 |
69 | - (void)dealloc {
70 | NSLog(@"dealloc of %@", [self class]);
71 | if (nil != [self superview]) {
72 | [self removeFromSuperview];
73 | }
74 | }
75 |
76 | #pragma mark - Pubic Structure
77 |
78 |
79 | + (instancetype)popUpDialogViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock {
80 | view = (nil == view) ?[UIApplication sharedApplication].keyWindow : view;
81 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:backgroundType];
82 |
83 |
84 | [view addSubview:popView];
85 |
86 | [popView setHeadIconImg:iconImg];
87 |
88 | [popView setHeadTitle:(nil == title) ? @"" : title];
89 |
90 | [popView setContent:(nil == content) ? @"" : content];
91 |
92 | [popView configureButtonWithTitles:titles confirmTitleColor:confirmBtnTextColor otherTitleColor:otherBtnTextColor];
93 |
94 | [popView setButtonPressedBlock:buttonPressedBlock];
95 |
96 |
97 | return popView;
98 | }
99 |
100 | + (instancetype)popUpDialogViewInView:(UIView *)view
101 | iconImg:(UIImage *)iconImg
102 | backgroundStyle:(ZHPopupViewBackgroundType)backgroundType
103 | title:(NSString *)title
104 | content:(NSString *)content
105 | buttonTitles:(NSArray *)titles
106 | confirmBtnTextColor:(UIColor *)confirmBtnTextColor
107 | otherBtnTextColor:(UIColor *)otherBtnTextColor
108 | buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock
109 | viewDismissedBlock:(void (^)())viewDismissedBlock
110 | {
111 | ZHPopupView *popView = [ZHPopupView popUpDialogViewInView:view
112 | iconImg:iconImg
113 | backgroundStyle:backgroundType
114 | title:title
115 | content:content
116 | buttonTitles:titles
117 | confirmBtnTextColor:confirmBtnTextColor
118 | otherBtnTextColor:otherBtnTextColor
119 | buttonPressedBlock:buttonPressedBlock];
120 |
121 | [popView setViewDismissedBlock:viewDismissedBlock];
122 |
123 | return popView;
124 | }
125 |
126 | + (instancetype)popupNormalAlertViewInView:(UIView *)view backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock {
127 |
128 | view = (nil == view) ?[UIApplication sharedApplication].keyWindow : view;
129 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:backgroundType];
130 |
131 | [view addSubview:popView];
132 |
133 | [popView setHeadTitle:(nil == title) ? @"" : title];
134 | [popView setHeadTitleFontSize:14.0f];
135 |
136 | [popView setContent:(nil == content) ? @"" : content];
137 | [popView setContentTextAlignment:NSTextAlignmentCenter];
138 |
139 | [popView configureButtonWithTitles:titles confirmTitleColor:confirmBtnTextColor otherTitleColor:otherBtnTextColor];
140 |
141 | [popView setButtonPressedBlock:buttonPressedBlock];
142 |
143 |
144 | return popView;
145 |
146 | }
147 |
148 | + (instancetype)popupNormalAlertViewInView:(UIView *)view
149 | backgroundStyle:(ZHPopupViewBackgroundType)backgroundType
150 | title:(NSString *)title
151 | content:(NSString *)content
152 | buttonTitles:(NSArray *)titles
153 | confirmBtnTextColor:(UIColor *)confirmBtnTextColor
154 | otherBtnTextColor:(UIColor *)otherBtnTextColor
155 | buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock
156 | viewDismissedBlock:(void (^)())viewDismissedBlock
157 | {
158 | ZHPopupView *popView = [ZHPopupView popupNormalAlertViewInView:view
159 | backgroundStyle:backgroundType
160 | title:title
161 | content:content
162 | buttonTitles:titles
163 | confirmBtnTextColor:confirmBtnTextColor
164 | otherBtnTextColor:otherBtnTextColor
165 | buttonPressedBlock:buttonPressedBlock];
166 |
167 | [popView setViewDismissedBlock:viewDismissedBlock];
168 |
169 | return popView;
170 | }
171 |
172 | + (instancetype)popupViewOnKeyWindow {
173 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
174 |
175 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:keyWindow backgroundType:ZHPopupViewBackgroundType_SimpleOpacity];
176 | [keyWindow addSubview:popView];
177 |
178 | return popView;
179 | }
180 |
181 |
182 | + (instancetype)popupBlurViewOnKeyWindow {
183 |
184 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
185 |
186 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:keyWindow backgroundType:ZHPopupViewBackgroundType_Blur];
187 | [keyWindow addSubview:popView];
188 |
189 | return popView;
190 | }
191 |
192 | + (instancetype)popupViewInView:(UIView *)view {
193 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:ZHPopupViewBackgroundType_SimpleOpacity];
194 |
195 | [view addSubview:popView];
196 |
197 | return popView;
198 | }
199 |
200 | + (instancetype)popupBlurViewInView:(UIView *)view {
201 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:ZHPopupViewBackgroundType_Blur];
202 |
203 | [view addSubview:popView];
204 |
205 | return popView;
206 | }
207 |
208 |
209 | - (void)layoutSubviews {
210 | [super layoutSubviews];
211 |
212 |
213 | CGFloat previousYPos = kZHPopupView_HeadInterval;
214 | CGRect frame;
215 |
216 | if (nil != _headIconImgView && nil != [_headIconImgView superview] && nil != _headIconImg) {
217 |
218 | frame = _headIconImgView.frame;
219 | frame.origin.y = kZHPopupView_HeadInterval;
220 | [_headIconImgView setFrame:frame];
221 | previousYPos = CGRectGetMaxY(_headIconImgView.frame);
222 | }
223 |
224 | if (nil != _headTitleLbl && nil != [_headTitleLbl superview]) {
225 | frame = _headTitleLbl.frame;
226 | if (nil == _headTitleLbl.text || _headTitleLbl.text.length <= 0) {
227 | //hide by height
228 | frame.size.height = 0.0f;
229 | } else {
230 | CGSize textSize = [_headTitleLbl.text sizeWithAttributes:@{
231 | NSFontAttributeName : _headTitleLbl.font
232 | }];
233 | frame.size.height = textSize.height;
234 | frame.origin.y = (previousYPos == kZHPopupView_HeadInterval) ? kZHPopupView_HeadInterval : previousYPos + 20.0f;
235 |
236 | }
237 | [_headTitleLbl setFrame:frame];
238 | previousYPos = CGRectGetMaxY(_headTitleLbl.frame);
239 |
240 |
241 |
242 | }
243 |
244 | [_contentTextView sizeToFit];
245 | frame = _contentTextView.frame;
246 | frame.origin.y = (previousYPos == kZHPopupView_HeadInterval) ? kZHPopupView_HeadInterval : previousYPos +25.0f;
247 | if (self.contentTextAlignment == NSTextAlignmentCenter) {
248 | frame.origin.x = self.container.frame.size.width / 2 - frame.size.width / 2;
249 | } else if (self.contentTextAlignment == NSTextAlignmentLeft) {
250 | frame.origin.x = kZHPopupView_InsideLeftInterval;
251 | } else {
252 | frame.origin.x = self.container.frame.size.width - kZHPopupView_InsideLeftInterval - frame.size.width;
253 | }
254 | [_contentTextView setFrame:frame];
255 | [_contentTextView setTextContainerInset:UIEdgeInsetsZero];
256 |
257 |
258 |
259 |
260 | //again adjust frame
261 |
262 | if (_contentTextView.text.length <= 0) {
263 | //there's no content displaying,need to trim the space
264 |
265 | frame = _headTitleLbl.frame;
266 | frame.origin.y = self.container.frame.size.height - kZHPopupView_buttonDefaultHeight - 25.0f - _headTitleLbl.frame.size.height;
267 | [_headTitleLbl setFrame:frame];
268 |
269 | frame = self.container.frame;
270 | frame.size.height = frame.size.height - CGRectGetMinY(_headTitleLbl.frame) + 20.0f;
271 | frame.origin.y = self.frame.size.height / 2 - frame.size.height / 2;
272 | [self.container setFrame:frame];
273 | } else {
274 |
275 | //has content
276 | //adjust button Area
277 |
278 | CGFloat containerHeight = CGRectGetMaxY(_contentTextView.frame) + 20.0f;
279 | if (nil != _buttonArea) {
280 | frame = _buttonArea.frame;
281 | frame.origin.y = CGRectGetMaxY(_contentTextView.frame) + 25.0f;
282 | [_buttonArea setFrame:frame];
283 | containerHeight = CGRectGetMaxY(_buttonArea.frame);
284 | }
285 |
286 |
287 | frame = self.container.frame;
288 | frame.size.height = containerHeight;//CGRectGetMaxY(_buttonArea.frame);
289 | frame.origin.y = self.frame.size.height / 2 - frame.size.height / 2;
290 | [self.container setFrame:frame];
291 | }
292 |
293 |
294 | }
295 |
296 | #pragma mark - Initialization
297 |
298 | - (void)_initialization {
299 | [self _createView];
300 | }
301 |
302 | #pragma mark - Events
303 |
304 | - (void)pressedOnTitleButton:(UIButton *)sender {
305 |
306 | NSInteger idx = sender.tag - 233;
307 |
308 | [self disappear];
309 |
310 | if (nil != self.buttonPressedBlock) {
311 | self.buttonPressedBlock(idx);
312 | }
313 |
314 |
315 | }
316 |
317 | - (void)configureButtonWithTitles:(NSArray *)titles confirmTitleColor:(UIColor *)confirmTitleColor otherTitleColor:(UIColor *)otherTitleColor {
318 | if (nil == titles || titles.count <= 0) {
319 | return;
320 | }
321 | [[self.buttonArea subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *_Nonnull stop) {
322 | [obj removeFromSuperview];
323 | }];
324 |
325 |
326 | confirmTitleColor = (nil == confirmTitleColor) ? COLOR_MAINBLUE : confirmTitleColor;
327 | otherTitleColor = (nil == otherTitleColor) ? COLOR_333333 : otherTitleColor;
328 |
329 | __block CGFloat perWidth = self.container.frame.size.width / titles.count;
330 |
331 | [titles enumerateObjectsUsingBlock:^(NSString *title, NSUInteger idx, BOOL *stop) {
332 | if (nil == title || title.length <= 0) {
333 | return;
334 | }
335 |
336 | UIButton *btn = [self buttonWithTitle:title textColor:(idx == titles.count - 1) ? confirmTitleColor : otherTitleColor width:perWidth xPos:idx * perWidth yPos:0];
337 | [btn setTag:idx + 233];
338 | [btn addTarget:self action:@selector(pressedOnTitleButton:) forControlEvents:UIControlEventTouchUpInside];
339 | [self.buttonArea addSubview:btn];
340 |
341 | if (idx != titles.count - 1) {
342 | UIView *seperator = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame), CGRectGetMinY(btn.frame), 0.5f, btn.frame.size.height)];
343 | [seperator setBackgroundColor:COLOR_E5E5E5];
344 | [self.buttonArea addSubview:seperator];
345 | }
346 |
347 | }];
348 |
349 | UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.container.frame.size.width, 0.5f)];
350 | [line setBackgroundColor:COLOR_E5E5E5];
351 | [self.buttonArea addSubview:line];
352 |
353 | if (nil == [self.buttonArea superview]) {
354 | [self.container addSubview:self.buttonArea];
355 | }
356 |
357 | [self layoutSubviews];
358 |
359 | }
360 |
361 | - (UIButton *)buttonWithTitle:(NSString *)title textColor:(UIColor *)textColor width:(CGFloat)width xPos:(CGFloat)xPos yPos:(CGFloat)yPos {
362 |
363 | UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(xPos, yPos, width, 40.0f)];
364 |
365 | [button setTitleColor:textColor forState:UIControlStateNormal];
366 | [button setTitle:title forState:UIControlStateNormal];
367 | [button.titleLabel setFont:[UIFont systemFontOfSize:14.0f]];
368 |
369 |
370 | return button;
371 | }
372 |
373 | #pragma mark - Properties
374 |
375 |
376 | - (void)setHeadTextAlignment:(NSTextAlignment)headTextAlignment {
377 | _headTextAlignment = headTextAlignment;
378 |
379 | [self.headTitleLbl setTextAlignment:headTextAlignment];
380 |
381 | }
382 |
383 | - (void)setContentTextAlignment:(NSTextAlignment)contentTextAlignment {
384 | _contentTextAlignment = contentTextAlignment;
385 |
386 | [self.contentTextView setTextAlignment:contentTextAlignment];
387 | }
388 |
389 | - (void)setHeadTitleFontSize:(CGFloat)headTitleFontSize {
390 | _headTitleFontSize = headTitleFontSize;
391 |
392 | [self.headTitleLbl setFont:[UIFont systemFontOfSize:headTitleFontSize]];
393 |
394 | [self layoutSubviews];
395 | }
396 |
397 | - (void)setContentTextFontSize:(CGFloat)contentTextFontSize {
398 | _contentTextFontSize = contentTextFontSize;
399 | [self.contentTextView setFont:[UIFont systemFontOfSize:contentTextFontSize]];
400 | [self layoutSubviews];
401 | }
402 |
403 |
404 | - (void)setHeadTitleColor:(UIColor *)headTitleColor {
405 | _headTitleColor = headTitleColor;
406 |
407 | [self.headTitleLbl setTextColor:_headTitleColor];
408 | }
409 |
410 | - (void)setContentTextColor:(UIColor *)contentTextColor {
411 | _contentTextColor = contentTextColor;
412 |
413 | [self.contentTextView setTextColor:contentTextColor];
414 | }
415 |
416 | - (void)setHeadIconImg:(UIImage *)headIconImg {
417 | _headIconImg = headIconImg;
418 | [self.headIconImgView setImage:headIconImg];
419 | if (nil == [self.headIconImgView superview]) {
420 | [self.container addSubview:self.headIconImgView];
421 | }
422 | [self layoutSubviews];
423 | }
424 |
425 | - (void)setHeadTitle:(NSString *)headTitle {
426 |
427 | _headTitle = headTitle;
428 | [self.headTitleLbl setText:headTitle];
429 | if (nil == [self.headTitleLbl superview]) {
430 | [self.container addSubview:self.headTitleLbl];
431 | }
432 |
433 | [self layoutSubviews];
434 | }
435 |
436 | - (void)setContent:(NSString *)content {
437 |
438 | _content = content;
439 | [self.contentTextView setText:content];
440 | if (nil == [self.contentTextView superview]) {
441 | [self.container addSubview:self.contentTextView];
442 | }
443 |
444 | [self layoutSubviews];
445 | }
446 |
447 | - (UIView *)buttonArea {
448 | if (nil == _buttonArea) {
449 |
450 | _buttonArea = [[UIView alloc] initWithFrame:CGRectMake(0, self.container.frame.size.height - kZHPopupView_buttonDefaultHeight, self.container.frame.size.width, kZHPopupView_buttonDefaultHeight)];
451 |
452 | }
453 | return _buttonArea;
454 | }
455 |
456 | - (UIImageView *)headIconImgView {
457 | if (nil == _headIconImgView) {
458 | _headIconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.container.frame.size.width / 2 - 17.5f, kZHPopupView_HeadInterval, 35.0f, 35.0f)];
459 | [_headIconImgView setContentMode:UIViewContentModeScaleAspectFit];
460 | }
461 | return _headIconImgView;
462 | }
463 |
464 | - (UILabel *)headTitleLbl {
465 | if (nil == _headTitleLbl) {
466 | _headTitleLbl = [[UILabel alloc] initWithFrame:CGRectMake(kZHPopupView_InsideLeftInterval, 0.0f, self.container.frame.size.width - 2 * kZHPopupView_InsideLeftInterval, 20.0f)];
467 | [_headTitleLbl setTextColor:[UIColor darkTextColor]];
468 | [_headTitleLbl setFont:[UIFont systemFontOfSize:20.0f]];
469 | [_headTitleLbl setTextAlignment:NSTextAlignmentCenter];
470 |
471 | }
472 | return _headTitleLbl;
473 | }
474 |
475 | - (UITextView *)contentTextView {
476 | if (nil == _contentTextView) {
477 | _contentTextView = [[UITextView alloc] initWithFrame:CGRectMake(kZHPopupView_InsideLeftInterval, 0.0f, self.container.frame.size.width - 2 * kZHPopupView_InsideLeftInterval, 20.0f)];
478 | [_contentTextView setTextColor:[UIColor darkTextColor]];
479 | [_contentTextView setFont:[UIFont systemFontOfSize:14.0f]];
480 | [_contentTextView setBackgroundColor:[UIColor clearColor]];
481 | [_contentTextView setUserInteractionEnabled:NO];
482 | [_contentTextView setScrollEnabled:NO];
483 | [_contentTextView setEditable:NO];
484 | }
485 | return _contentTextView;
486 | }
487 |
488 | - (UIView *)container {
489 | if (nil == _container) {
490 |
491 | CGFloat xPos = kZHPopupViewContainerLeftRightInterval;
492 | CGFloat yPos = ((nil != self.parentView) ? self.parentView.bounds.size.height / 2 : kZHPopupView_ScreenHeight / 2) - kZHPopupViewContainerDefaultHeight / 2;
493 | CGFloat width = ((nil != self.parentView) ? self.parentView.bounds.size.width : kZHPopupView_ScreenWidth) - 2 * kZHPopupViewContainerLeftRightInterval;
494 | CGFloat height = kZHPopupViewContainerDefaultHeight;
495 |
496 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(xPos, yPos, width, height)];
497 | [view setBackgroundColor:[UIColor whiteColor]];
498 | [view.layer setCornerRadius:5.0f];
499 | [view.layer setMasksToBounds:YES];
500 |
501 | // [view dropShadowWithShadowColor:[UIColor colorWithWhite:0.0f alpha:0.8f] offset:CGSizeMake(0, 3.0f) opacity:0.5f radius:10.0f];
502 | _container = view;
503 | view = nil;
504 | }
505 |
506 | return _container;
507 | }
508 |
509 |
510 | #pragma mark - Display Event
511 |
512 |
513 | - (void)present {
514 |
515 | if (nil == self.parentView) {
516 | return;
517 | }
518 | if (nil == [self superview]) {
519 |
520 | [self.parentView addSubview:self];
521 | }
522 |
523 | [self.layer setOpacity:0.0f];
524 | [_container.layer setOpacity:0.0f];
525 |
526 |
527 | [UIView animateWithDuration:0.2f animations:^{
528 | [self.layer setOpacity:1.0f];
529 | [_container.layer setOpacity:1.0f];
530 | } completion:^(BOOL finished) {
531 |
532 |
533 | // CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
534 | //
535 |
536 | // animation.duration = 0.08f;
537 | // animation.autoreverses = YES;
538 | //
539 |
540 | // animation.fromValue = [NSNumber numberWithFloat:1.0f];
541 | // animation.toValue = [NSNumber numberWithFloat:1.03f];
542 | //
543 |
544 | // [_container.layer addAnimation:animation forKey:@"scale-layer"];
545 |
546 | }];
547 |
548 | }
549 |
550 | - (void)disappear {
551 |
552 | [UIView animateWithDuration:0.1f animations:^{
553 | [self.layer setOpacity:0.0f];
554 | } completion:^(BOOL finished) {
555 | [self removeFromSuperview];
556 | }];
557 |
558 | }
559 |
560 | #pragma mark - Background Gesture
561 |
562 | - (void)tappedOnBackground:(UITapGestureRecognizer *)tapGesture {
563 |
564 | CGPoint location = [tapGesture locationInView:self];
565 | if (CGRectContainsPoint(self.container.frame, location)) {
566 | return;
567 | }
568 | [self disappear];
569 |
570 | if (self.viewDismissedBlock != nil) {
571 | _viewDismissedBlock();
572 | }
573 | }
574 |
575 | #pragma mark - View
576 |
577 |
578 | - (void)_configureBackgroundBlur {
579 | //structure view
580 | UIGraphicsBeginImageContext(self.parentView.frame.size);
581 | CGContextRef context = UIGraphicsGetCurrentContext();
582 | [self.parentView.layer renderInContext:context];
583 | UIImage *clipImg = UIGraphicsGetImageFromCurrentImageContext();
584 | UIGraphicsEndImageContext();
585 |
586 |
587 | UIColor *tintColor = [UIColor colorWithWhite:0.10 alpha:0.3];
588 |
589 | UIImage *blurImg = [UIImageEffects imageByApplyingBlurToImage:clipImg withRadius:10 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
590 | UIImageView *bgImgView = [[UIImageView alloc] initWithImage:blurImg];
591 |
592 | [self addSubview:bgImgView];
593 |
594 |
595 | }
596 |
597 | - (void)_createView {
598 |
599 | [self.layer setOpacity:0.0f];
600 |
601 | if (self.backgroundType == ZHPopupViewBackgroundType_SimpleOpacity) {
602 | self.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.5f];
603 | } else {
604 | [self _configureBackgroundBlur];
605 | }
606 |
607 |
608 | [self addSubview:[self container]];
609 |
610 | //Tap gesture
611 |
612 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tappedOnBackground:)];
613 | [self addGestureRecognizer:tapGesture];
614 |
615 |
616 | }
617 | @end
618 |
--------------------------------------------------------------------------------
/ZHPopupView/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 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UIAppFonts
34 |
35 | comic-sans.ttf
36 |
37 | UISupportedInterfaceOrientations
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationLandscapeLeft
41 | UIInterfaceOrientationLandscapeRight
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/ZHPopupView/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/ZHPopupView/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "ZHPopupView.h"
11 |
12 | #define kRandomText @"\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\""
13 |
14 | @interface ViewController ()
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | // Do any additional setup after loading the view, typically from a nib.
23 | }
24 |
25 | - (void)didReceiveMemoryWarning {
26 | [super didReceiveMemoryWarning];
27 | // Dispose of any resources that can be recreated.
28 | }
29 |
30 | #pragma mark - Pressed Events
31 |
32 | - (IBAction)pressedOnAlertViewPopup:(id)sender {
33 |
34 | ZHPopupView *popupView = [ZHPopupView popupNormalAlertViewInView:nil
35 | backgroundStyle:ZHPopupViewBackgroundType_SimpleOpacity
36 | title:@"Tips"
37 | content:@"Confirm to delete/remove?"
38 | buttonTitles:@[@"Cancel", @"Confirm"]
39 | confirmBtnTextColor:nil otherBtnTextColor:nil
40 | buttonPressedBlock:^(NSInteger btnIdx) {
41 |
42 |
43 | }];
44 | [popupView present];
45 |
46 | }
47 |
48 | - (IBAction)pressedOnDialogViewPopup:(id)sender {
49 |
50 |
51 | ZHPopupView *popupView = [ZHPopupView popUpDialogViewInView:nil
52 | iconImg:[UIImage imageNamed:@"correct_icon"]
53 | backgroundStyle:ZHPopupViewBackgroundType_SimpleOpacity
54 | title:@"Lorem Ipsum"
55 | content:kRandomText
56 | buttonTitles:@[@"Cancel", @"Confirm"]
57 | confirmBtnTextColor:nil otherBtnTextColor:nil
58 | buttonPressedBlock:^(NSInteger btnIdx) {
59 |
60 |
61 | }];
62 | [popupView present];
63 |
64 |
65 | }
66 |
67 | - (IBAction)pressedOnBlurAlertViewPopup:(id)sender {
68 |
69 | ZHPopupView *popupView = [ZHPopupView popupNormalAlertViewInView:nil
70 | backgroundStyle:ZHPopupViewBackgroundType_Blur
71 | title:@"Tips"
72 | content:@"Confirm to delete/remove?"
73 | buttonTitles:@[@"Cancel", @"Confirm"]
74 | confirmBtnTextColor:nil otherBtnTextColor:nil
75 | buttonPressedBlock:^(NSInteger btnIdx) {
76 |
77 |
78 | }];
79 | [popupView present];
80 |
81 |
82 | }
83 |
84 | - (IBAction)pressedOnBlurDialogViewPopup:(id)sender {
85 | ZHPopupView *popupView = [ZHPopupView popUpDialogViewInView:nil
86 | iconImg:[UIImage imageNamed:@"correct_icon"]
87 | backgroundStyle:ZHPopupViewBackgroundType_Blur
88 | title:@"Lorem Ipsum"
89 | content:kRandomText
90 | buttonTitles:@[@"Cancel", @"Confirm"]
91 | confirmBtnTextColor:nil otherBtnTextColor:nil
92 | buttonPressedBlock:^(NSInteger btnIdx) {
93 |
94 |
95 | }];
96 | [popupView present];
97 | }
98 |
99 | - (IBAction)pressedOnCustomButtonFontDialogViewPopup:(id)sender {
100 | UIFont *titleFont = [UIFont fontWithName:@"ComicSansMS" size:15];
101 | UIFont *buttonFont = [UIFont fontWithName:@"ComicSansMS" size:13];
102 | UIFont *contentFont = [UIFont fontWithName:@"ComicSansMS" size:14];
103 |
104 | ZHPopupView *popupView = [ZHPopupView popUpDialogWithCustomFontViewInView:nil
105 | iconImg:[UIImage imageNamed:@"correct_icon"]
106 | backgroundStyle:ZHPopupViewBackgroundType_Blur
107 | title:@"Lorem Ipsum" titleFont:titleFont
108 | content:kRandomText contentFont:contentFont
109 | buttonTitles:@[@"Cancel", @"Confirm"]
110 | confirmBtnTextColor:nil confirmTitleFont:buttonFont otherBtnTextColor:nil otherBtnFont:buttonFont buttonPressedBlock:nil];
111 | [popupView present];
112 | }
113 |
114 | @end
115 |
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/UIColor+HexString.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+HexString.h
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIColor (HexString)
12 | +(UIColor*)colorWithHexString:(NSString*)hex;
13 | @end
14 |
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/UIColor+HexString.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+HexString.m
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. All rights reserved.
7 | //
8 |
9 | #import "UIColor+HexString.h"
10 |
11 | @implementation UIColor (HexString)
12 |
13 |
14 | +(UIColor*)colorWithHexString:(NSString*)hex
15 | {
16 | NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
17 |
18 | // String should be 6 or 8 characters
19 | if ([cString length] < 6) return [UIColor grayColor];
20 |
21 | // strip 0X if it appears
22 | if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];
23 |
24 | if ([cString length] != 6) return [UIColor grayColor];
25 |
26 | // Separate into r, g, b substrings
27 | NSRange range;
28 | range.location = 0;
29 | range.length = 2;
30 | NSString *rString = [cString substringWithRange:range];
31 |
32 | range.location = 2;
33 | NSString *gString = [cString substringWithRange:range];
34 |
35 | range.location = 4;
36 | NSString *bString = [cString substringWithRange:range];
37 |
38 | // Scan values
39 | unsigned int r, g, b;
40 | [[NSScanner scannerWithString:rString] scanHexInt:&r];
41 | [[NSScanner scannerWithString:gString] scanHexInt:&g];
42 | [[NSScanner scannerWithString:bString] scanHexInt:&b];
43 |
44 | return [UIColor colorWithRed:((float) r / 255.0f)
45 | green:((float) g / 255.0f)
46 | blue:((float) b / 255.0f)
47 | alpha:1.0f];
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/UIImageEffects.h:
--------------------------------------------------------------------------------
1 | /*
2 | File: UIImageEffects.h
3 | Abstract: This class contains methods to apply blur and tint effects to an image.
4 | This is the code you’ll want to look out to find out how to use vImage to
5 | efficiently calculate a blur.
6 | Version: 1.1
7 |
8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
9 | Inc. ("Apple") in consideration of your agreement to the following
10 | terms, and your use, installation, modification or redistribution of
11 | this Apple software constitutes acceptance of these terms. If you do
12 | not agree with these terms, please do not use, install, modify or
13 | redistribute this Apple software.
14 |
15 | In consideration of your agreement to abide by the following terms, and
16 | subject to these terms, Apple grants you a personal, non-exclusive
17 | license, under Apple's copyrights in this original Apple software (the
18 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
19 | Software, with or without modifications, in source and/or binary forms;
20 | provided that if you redistribute the Apple Software in its entirety and
21 | without modifications, you must retain this notice and the following
22 | text and disclaimers in all such redistributions of the Apple Software.
23 | Neither the name, trademarks, service marks or logos of Apple Inc. may
24 | be used to endorse or promote products derived from the Apple Software
25 | without specific prior written permission from Apple. Except as
26 | expressly stated in this notice, no other rights or licenses, express or
27 | implied, are granted by Apple herein, including but not limited to any
28 | patent rights that may be infringed by your derivative works or by other
29 | works in which the Apple Software may be incorporated.
30 |
31 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
32 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
33 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
34 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
35 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
36 |
37 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
38 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
41 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
42 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
43 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
44 | POSSIBILITY OF SUCH DAMAGE.
45 |
46 | Copyright (C) 2014 Apple Inc. All Rights Reserved.
47 |
48 | */
49 |
50 | #import
51 | #import
52 | @interface UIImageEffects : NSObject
53 |
54 | + (UIImage*)imageByApplyingLightEffectToImage:(UIImage*)inputImage;
55 | + (UIImage*)imageByApplyingExtraLightEffectToImage:(UIImage*)inputImage;
56 | + (UIImage*)imageByApplyingDarkEffectToImage:(UIImage*)inputImage;
57 | + (UIImage*)imageByApplyingTintEffectWithColor:(UIColor *)tintColor toImage:(UIImage*)inputImage;
58 |
59 | //| ----------------------------------------------------------------------------
60 | //! Applies a blur, tint color, and saturation adjustment to @a inputImage,
61 | //! optionally within the area specified by @a maskImage.
62 | //!
63 | //! @param inputImage
64 | //! The source image. A modified copy of this image will be returned.
65 | //! @param blurRadius
66 | //! The radius of the blur in points.
67 | //! @param tintColor
68 | //! An optional UIColor object that is uniformly blended with the
69 | //! result of the blur and saturation operations. The alpha channel
70 | //! of this color determines how strong the tint is.
71 | //! @param saturationDeltaFactor
72 | //! A value of 1.0 produces no change in the resulting image. Values
73 | //! less than 1.0 will desaturation the resulting image while values
74 | //! greater than 1.0 will have the opposite effect.
75 | //! @param maskImage
76 | //! If specified, @a inputImage is only modified in the area(s) defined
77 | //! by this mask. This must be an image mask or it must meet the
78 | //! requirements of the mask parameter of CGContextClipToMask.
79 | + (UIImage*)imageByApplyingBlurToImage:(UIImage*)inputImage withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
80 |
81 | @end
82 |
83 |
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/UIImageEffects.m:
--------------------------------------------------------------------------------
1 | /*
2 | File: UIImageEffects.m
3 | Abstract: This class contains methods to apply blur and tint effects to an image.
4 | This is the code you’ll want to look out to find out how to use vImage to
5 | efficiently calculate a blur.
6 | Version: 1.1
7 |
8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
9 | Inc. ("Apple") in consideration of your agreement to the following
10 | terms, and your use, installation, modification or redistribution of
11 | this Apple software constitutes acceptance of these terms. If you do
12 | not agree with these terms, please do not use, install, modify or
13 | redistribute this Apple software.
14 |
15 | In consideration of your agreement to abide by the following terms, and
16 | subject to these terms, Apple grants you a personal, non-exclusive
17 | license, under Apple's copyrights in this original Apple software (the
18 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
19 | Software, with or without modifications, in source and/or binary forms;
20 | provided that if you redistribute the Apple Software in its entirety and
21 | without modifications, you must retain this notice and the following
22 | text and disclaimers in all such redistributions of the Apple Software.
23 | Neither the name, trademarks, service marks or logos of Apple Inc. may
24 | be used to endorse or promote products derived from the Apple Software
25 | without specific prior written permission from Apple. Except as
26 | expressly stated in this notice, no other rights or licenses, express or
27 | implied, are granted by Apple herein, including but not limited to any
28 | patent rights that may be infringed by your derivative works or by other
29 | works in which the Apple Software may be incorporated.
30 |
31 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
32 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
33 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
34 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
35 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
36 |
37 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
38 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
41 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
42 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
43 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
44 | POSSIBILITY OF SUCH DAMAGE.
45 |
46 | Copyright (C) 2014 Apple Inc. All Rights Reserved.
47 |
48 | */
49 |
50 | #import "UIImageEffects.h"
51 |
52 | @import Accelerate;
53 |
54 | @implementation UIImageEffects
55 |
56 | #pragma mark -
57 | #pragma mark - Effects
58 |
59 | //| ----------------------------------------------------------------------------
60 | + (UIImage *)imageByApplyingLightEffectToImage:(UIImage*)inputImage
61 | {
62 | UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3];
63 | return [self imageByApplyingBlurToImage:inputImage withRadius:60 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
64 | }
65 |
66 |
67 | //| ----------------------------------------------------------------------------
68 | + (UIImage *)imageByApplyingExtraLightEffectToImage:(UIImage*)inputImage
69 | {
70 | UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82];
71 | return [self imageByApplyingBlurToImage:inputImage withRadius:40 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
72 | }
73 |
74 |
75 | //| ----------------------------------------------------------------------------
76 | + (UIImage *)imageByApplyingDarkEffectToImage:(UIImage*)inputImage
77 | {
78 | UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73];
79 | return [self imageByApplyingBlurToImage:inputImage withRadius:40 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
80 | }
81 |
82 |
83 | //| ----------------------------------------------------------------------------
84 | + (UIImage *)imageByApplyingTintEffectWithColor:(UIColor *)tintColor toImage:(UIImage*)inputImage
85 | {
86 | const CGFloat EffectColorAlpha = 0.6;
87 | UIColor *effectColor = tintColor;
88 | size_t componentCount = CGColorGetNumberOfComponents(tintColor.CGColor);
89 | if (componentCount == 2) {
90 | CGFloat b;
91 | if ([tintColor getWhite:&b alpha:NULL]) {
92 | effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha];
93 | }
94 | }
95 | else {
96 | CGFloat r, g, b;
97 | if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) {
98 | effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha];
99 | }
100 | }
101 | return [self imageByApplyingBlurToImage:inputImage withRadius:20 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil];
102 | }
103 |
104 | #pragma mark -
105 | #pragma mark - Implementation
106 |
107 | //| ----------------------------------------------------------------------------
108 | + (UIImage*)imageByApplyingBlurToImage:(UIImage*)inputImage withRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage
109 | {
110 | #define ENABLE_BLUR 1
111 | #define ENABLE_SATURATION_ADJUSTMENT 1
112 | #define ENABLE_TINT 1
113 |
114 | // Check pre-conditions.
115 | if (inputImage.size.width < 1 || inputImage.size.height < 1)
116 | {
117 | NSLog(@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", inputImage.size.width, inputImage.size.height, inputImage);
118 | return nil;
119 | }
120 | if (!inputImage.CGImage)
121 | {
122 | NSLog(@"*** error: inputImage must be backed by a CGImage: %@", inputImage);
123 | return nil;
124 | }
125 | if (maskImage && !maskImage.CGImage)
126 | {
127 | NSLog(@"*** error: effectMaskImage must be backed by a CGImage: %@", maskImage);
128 | return nil;
129 | }
130 |
131 | BOOL hasBlur = blurRadius > __FLT_EPSILON__;
132 | BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__;
133 |
134 | CGImageRef inputCGImage = inputImage.CGImage;
135 | CGFloat inputImageScale = inputImage.scale;
136 | CGBitmapInfo inputImageBitmapInfo = CGImageGetBitmapInfo(inputCGImage);
137 | CGImageAlphaInfo inputImageAlphaInfo = (inputImageBitmapInfo & kCGBitmapAlphaInfoMask);
138 |
139 | CGSize outputImageSizeInPoints = inputImage.size;
140 | CGRect outputImageRectInPoints = { CGPointZero, outputImageSizeInPoints };
141 |
142 | // Set up output context.
143 | BOOL useOpaqueContext;
144 | if (inputImageAlphaInfo == kCGImageAlphaNone || inputImageAlphaInfo == kCGImageAlphaNoneSkipLast || inputImageAlphaInfo == kCGImageAlphaNoneSkipFirst)
145 | useOpaqueContext = YES;
146 | else
147 | useOpaqueContext = NO;
148 | UIGraphicsBeginImageContextWithOptions(outputImageRectInPoints.size, useOpaqueContext, inputImageScale);
149 | CGContextRef outputContext = UIGraphicsGetCurrentContext();
150 | CGContextScaleCTM(outputContext, 1.0, -1.0);
151 | CGContextTranslateCTM(outputContext, 0, -outputImageRectInPoints.size.height);
152 |
153 | if (hasBlur || hasSaturationChange)
154 | {
155 | vImage_Buffer effectInBuffer;
156 | vImage_Buffer scratchBuffer1;
157 |
158 | vImage_Buffer *inputBuffer;
159 | vImage_Buffer *outputBuffer;
160 |
161 | vImage_CGImageFormat format = {
162 | .bitsPerComponent = 8,
163 | .bitsPerPixel = 32,
164 | .colorSpace = NULL,
165 | // (kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little)
166 | // requests a BGRA buffer.
167 | .bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
168 | .version = 0,
169 | .decode = NULL,
170 | .renderingIntent = kCGRenderingIntentDefault
171 | };
172 |
173 | vImage_Error e = vImageBuffer_InitWithCGImage(&effectInBuffer, &format, NULL, inputImage.CGImage, kvImagePrintDiagnosticsToConsole);
174 | if (e != kvImageNoError)
175 | {
176 | NSLog(@"*** error: vImageBuffer_InitWithCGImage returned error code %zi for inputImage: %@", e, inputImage);
177 | UIGraphicsEndImageContext();
178 | return nil;
179 | }
180 |
181 | vImageBuffer_Init(&scratchBuffer1, effectInBuffer.height, effectInBuffer.width, format.bitsPerPixel, kvImageNoFlags);
182 | inputBuffer = &effectInBuffer;
183 | outputBuffer = &scratchBuffer1;
184 |
185 | #if ENABLE_BLUR
186 | if (hasBlur)
187 | {
188 | // A description of how to compute the box kernel width from the Gaussian
189 | // radius (aka standard deviation) appears in the SVG spec:
190 | // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
191 | //
192 | // For larger values of 's' (s >= 2.0), an approximation can be used: Three
193 | // successive box-blurs build a piece-wise quadratic convolution kernel, which
194 | // approximates the Gaussian kernel to within roughly 3%.
195 | //
196 | // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
197 | //
198 | // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
199 | //
200 | CGFloat inputRadius = blurRadius * inputImageScale;
201 | if (inputRadius - 2. < __FLT_EPSILON__)
202 | inputRadius = 2.;
203 | uint32_t radius = floor((inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5) / 2);
204 |
205 | radius |= 1; // force radius to be odd so that the three box-blur methodology works.
206 |
207 | NSInteger tempBufferSize = vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize | kvImageEdgeExtend);
208 | void *tempBuffer = malloc(tempBufferSize);
209 |
210 | vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
211 | vImageBoxConvolve_ARGB8888(outputBuffer, inputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
212 | vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, tempBuffer, 0, 0, radius, radius, NULL, kvImageEdgeExtend);
213 |
214 | free(tempBuffer);
215 |
216 | vImage_Buffer *temp = inputBuffer;
217 | inputBuffer = outputBuffer;
218 | outputBuffer = temp;
219 | }
220 | #endif
221 |
222 | #if ENABLE_SATURATION_ADJUSTMENT
223 | if (hasSaturationChange)
224 | {
225 | CGFloat s = saturationDeltaFactor;
226 | // These values appear in the W3C Filter Effects spec:
227 | // https://dvcs.w3.org/hg/FXTF/raw-file/default/filters/index.html#grayscaleEquivalent
228 | //
229 | CGFloat floatingPointSaturationMatrix[] = {
230 | 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
231 | 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
232 | 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
233 | 0, 0, 0, 1,
234 | };
235 | const int32_t divisor = 256;
236 | NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]);
237 | int16_t saturationMatrix[matrixSize];
238 | for (NSUInteger i = 0; i < matrixSize; ++i) {
239 | saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor);
240 | }
241 | vImageMatrixMultiply_ARGB8888(inputBuffer, outputBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
242 |
243 | vImage_Buffer *temp = inputBuffer;
244 | inputBuffer = outputBuffer;
245 | outputBuffer = temp;
246 | }
247 | #endif
248 |
249 | CGImageRef effectCGImage;
250 | if ( (effectCGImage = vImageCreateCGImageFromBuffer(inputBuffer, &format, &cleanupBuffer, NULL, kvImageNoAllocate, NULL)) == NULL ) {
251 | effectCGImage = vImageCreateCGImageFromBuffer(inputBuffer, &format, NULL, NULL, kvImageNoFlags, NULL);
252 | free(inputBuffer->data);
253 | }
254 | if (maskImage) {
255 | // Only need to draw the base image if the effect image will be masked.
256 | CGContextDrawImage(outputContext, outputImageRectInPoints, inputCGImage);
257 | }
258 |
259 | // draw effect image
260 | CGContextSaveGState(outputContext);
261 | if (maskImage)
262 | CGContextClipToMask(outputContext, outputImageRectInPoints, maskImage.CGImage);
263 | CGContextDrawImage(outputContext, outputImageRectInPoints, effectCGImage);
264 | CGContextRestoreGState(outputContext);
265 |
266 | // Cleanup
267 | CGImageRelease(effectCGImage);
268 | free(outputBuffer->data);
269 | }
270 | else
271 | {
272 | // draw base image
273 | CGContextDrawImage(outputContext, outputImageRectInPoints, inputCGImage);
274 | }
275 |
276 | #if ENABLE_TINT
277 | // Add in color tint.
278 | if (tintColor)
279 | {
280 | CGContextSaveGState(outputContext);
281 | CGContextSetFillColorWithColor(outputContext, tintColor.CGColor);
282 | CGContextFillRect(outputContext, outputImageRectInPoints);
283 | CGContextRestoreGState(outputContext);
284 | }
285 | #endif
286 |
287 | // Output image is ready.
288 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
289 | UIGraphicsEndImageContext();
290 |
291 | return outputImage;
292 | #undef ENABLE_BLUR
293 | #undef ENABLE_SATURATION_ADJUSTMENT
294 | #undef ENABLE_TINT
295 | }
296 |
297 |
298 | //| ----------------------------------------------------------------------------
299 | // Helper function to handle deferred cleanup of a buffer.
300 | //
301 | void cleanupBuffer(void *userData, void *buf_data)
302 | { free(buf_data); }
303 |
304 | @end
305 |
306 |
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/UIView+DropShadow.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by heyz3a on 16/4/25.
3 | // Copyright (c) 2016 heyz3a. All rights reserved.
4 | //
5 |
6 | #import
7 | #import
8 |
9 | @interface UIView (DropShadow)
10 |
11 | - (void)dropShadowWithShadowColor:(UIColor *)shadowColor offset:(CGSize)offset opacity:(CGFloat)opacity radius:(CGFloat)radius;
12 | @end
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/UIView+DropShadow.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by heyz3a on 16/4/25.
3 | // Copyright (c) 2016 heyz3a. All rights reserved.
4 | //
5 |
6 | #import "UIView+DropShadow.h"
7 |
8 |
9 | @implementation UIView (DropShadow)
10 | - (void)dropShadowWithShadowColor:(UIColor *)shadowColor offset:(CGSize)offset opacity:(CGFloat)opacity radius:(CGFloat)radius {
11 |
12 | // Creating shadow path for better performance
13 | CGMutablePathRef path = CGPathCreateMutable();
14 | CGPathAddRect(path, NULL, self.bounds);
15 | self.layer.shadowPath = path;
16 | CGPathCloseSubpath(path);
17 | CGPathRelease(path);
18 |
19 | self.layer.shadowColor = shadowColor.CGColor;
20 | self.layer.shadowOffset = offset;
21 | self.layer.shadowRadius = radius;
22 | self.layer.shadowOpacity = opacity;
23 |
24 | // Default clipsToBounds is YES, will clip off the shadow, so we disable it.
25 | self.clipsToBounds = NO;
26 | }
27 |
28 |
29 | @end
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/ZHPopupView.h:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupView.h
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 16/4/25.
6 | // Copyright © 2016年 zhhlmr. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | typedef enum {
13 | ZHPopupViewBackgroundType_SimpleOpacity = 0,
14 | ZHPopupViewBackgroundType_Blur = 1
15 |
16 | } ZHPopupViewBackgroundType;
17 |
18 | @interface ZHPopupView : UIView
19 |
20 |
21 | @property(nonatomic, strong) NSString *headTitle;// Title string
22 | @property(nonatomic, strong) NSString *content; // Content String
23 | @property(nonatomic, strong) UIImage *headIconImg; // head Icon Img
24 |
25 | @property(nonatomic, strong) UIColor *headTitleColor; // Title Color
26 | @property(nonatomic, strong) UIColor *contentTextColor; // Content Text Color
27 |
28 | @property(nonatomic, assign) CGFloat headTitleFontSize;// Title font size
29 | @property (nonatomic, strong) UIFont *headTitleFont; // Title custom font
30 |
31 | @property(nonatomic, assign) CGFloat contentTextFontSize;// Content font size
32 | @property (nonatomic, strong) UIFont *contentTextFont; // Content custom font
33 |
34 | @property(nonatomic, assign) NSTextAlignment contentTextAlignment;// Content text Alignment
35 | @property(nonatomic, assign) NSTextAlignment headTextAlignment; // Title Text Alignment
36 |
37 | @property(nonatomic, copy) void (^buttonPressedBlock)(NSInteger btnIdx); // Button Click/Pressed callback
38 |
39 |
40 | + (instancetype)popupViewInView:(UIView *)view;
41 |
42 | + (instancetype)popupBlurViewInView:(UIView *)view;
43 |
44 | + (instancetype)popupViewOnKeyWindow;
45 |
46 | + (instancetype)popupBlurViewOnKeyWindow;
47 |
48 | + (instancetype)popupNormalAlertViewInView:(UIView *)view backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock;
49 |
50 | + (instancetype)popUpDialogViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock;
51 |
52 | + (instancetype)popUpDialogWithCustomFontViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title titleFont:(UIFont *)titleFont content:(NSString *)content contentFont:(UIFont *)contentFont buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor confirmTitleFont:(UIFont *)confirmTitleFont otherBtnTextColor:(UIColor *)otherBtnTextColor otherBtnFont:(UIFont *)otherBtnFont buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock;
53 |
54 | - (void)configureButtonWithTitles:(NSArray *)titles confirmTitleColor:(UIColor *)confirmTitleColor otherTitleColor:(UIColor *)otherTitleColor;
55 |
56 | - (void)configureButtonWithTitles:(NSArray *)titles confirmTitleColor:(UIColor *)confirmTitleColor confirmTitleFont:(UIFont *)confirmTitleFont otherTitleColor:(UIColor *)otherTitleColor otherTitleFont:(UIFont *)otherTitleFont;
57 |
58 | - (void)present;
59 |
60 | - (void)disappear;
61 | @end
62 |
--------------------------------------------------------------------------------
/ZHPopupView/ZHPopupView/ZHPopupView.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZHPopupView.m
3 | // ZHPopupView
4 | //
5 | // Created by zhhlmr on 16/4/25.
6 | // Copyright © 2016年 zhhlmr. All rights reserved.
7 | //
8 |
9 | #import "ZHPopupView.h"
10 | #import "UIView+DropShadow.h"
11 | #import "UIColor+HexString.h"
12 | #import "UIImageEffects.h"
13 |
14 | #define kZHPopupViewContainerLeftRightInterval 55.0f
15 | #define kZHPopupView_ScreenHeight [UIScreen mainScreen].bounds.size.height
16 | #define kZHPopupView_ScreenWidth [UIScreen mainScreen].bounds.size.width
17 | #define kZHPopupViewContainerDefaultHeight 243.0f
18 |
19 | #define kZHPopupView_HeadInterval 20.0f
20 | #define kZHPopupView_InsideLeftInterval 25.0f
21 | #define kZHPopupView_buttonDefaultHeight 40.0f
22 |
23 | #define COLOR_333333 [UIColor colorWithHexString:@"333333"]
24 | #define COLOR_MAINRED [UIColor colorWithHexString:@"e31919"]
25 | #define COLOR_MAINBLUE [UIColor colorWithHexString:@"1bb4df"]
26 | #define COLOR_E5E5E5 [UIColor colorWithHexString:@"e5e5e5"]
27 |
28 |
29 | #define kScreen_Bounds [UIScreen mainScreen].bounds
30 | #define kScreen_Height [UIScreen mainScreen].bounds.size.height
31 | #define kScreen_Width [UIScreen mainScreen].bounds.size.width
32 |
33 |
34 | @interface ZHPopupView () {
35 |
36 | }
37 |
38 | @property(nonatomic, strong) UIImageView *headIconImgView;
39 | @property(nonatomic, strong) UILabel *headTitleLbl;
40 |
41 | @property(nonatomic, strong) UITextView *contentTextView;
42 | @property(nonatomic, strong) UIView *container;
43 | @property(nonatomic, weak) UIView *parentView;
44 | @property(nonatomic, assign) ZHPopupViewBackgroundType backgroundType;
45 |
46 | @property(nonatomic, strong) UIView *buttonArea;
47 |
48 |
49 | @end
50 |
51 | @implementation ZHPopupView
52 |
53 |
54 | - (instancetype)initWithFrame:(CGRect)frame {
55 | self = [super initWithFrame:frame];
56 | if (self) {
57 | [self _initialization];
58 |
59 |
60 | }
61 | return self;
62 | }
63 |
64 | - (instancetype)initPopUpViewInView:(UIView *)view backgroundType:(ZHPopupViewBackgroundType)backgroundType {
65 | self.parentView = view;
66 | self.backgroundType = backgroundType;
67 | self = [super initWithFrame:view.bounds];
68 | if (self) {
69 | [self _initialization];
70 | }
71 | return self;
72 | }
73 |
74 | - (void)dealloc {
75 | NSLog(@"dealloc of %@", [self class]);
76 | if (nil != [self superview]) {
77 | [self removeFromSuperview];
78 | }
79 | }
80 |
81 | #pragma mark - Pubic Structure
82 |
83 |
84 | + (instancetype)popUpDialogViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock {
85 | view = (nil == view) ?[UIApplication sharedApplication].keyWindow : view;
86 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:backgroundType];
87 |
88 |
89 | [view addSubview:popView];
90 |
91 | [popView setHeadIconImg:iconImg];
92 |
93 | [popView setHeadTitle:(nil == title) ? @"" : title];
94 |
95 | [popView setContent:(nil == content) ? @"" : content];
96 |
97 | [popView configureButtonWithTitles:titles confirmTitleColor:confirmBtnTextColor otherTitleColor:otherBtnTextColor];
98 |
99 | [popView setButtonPressedBlock:buttonPressedBlock];
100 |
101 |
102 | return popView;
103 | }
104 |
105 | + (instancetype)popupNormalAlertViewInView:(UIView *)view backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title content:(NSString *)content buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor otherBtnTextColor:(UIColor *)otherBtnTextColor buttonPressedBlock:(void (^)(NSInteger btnIdx))buttonPressedBlock {
106 |
107 | view = (nil == view) ?[UIApplication sharedApplication].keyWindow : view;
108 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:backgroundType];
109 |
110 | [view addSubview:popView];
111 |
112 | [popView setHeadTitle:(nil == title) ? @"" : title];
113 | [popView setHeadTitleFontSize:14.0f];
114 |
115 | [popView setContent:(nil == content) ? @"" : content];
116 | [popView setContentTextAlignment:NSTextAlignmentCenter];
117 |
118 | [popView configureButtonWithTitles:titles confirmTitleColor:confirmBtnTextColor otherTitleColor:otherBtnTextColor];
119 |
120 | [popView setButtonPressedBlock:buttonPressedBlock];
121 |
122 |
123 | return popView;
124 |
125 | }
126 |
127 | + (instancetype)popupViewOnKeyWindow {
128 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
129 |
130 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:keyWindow backgroundType:ZHPopupViewBackgroundType_SimpleOpacity];
131 | [keyWindow addSubview:popView];
132 |
133 | return popView;
134 | }
135 |
136 |
137 | + (instancetype)popupBlurViewOnKeyWindow {
138 |
139 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
140 |
141 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:keyWindow backgroundType:ZHPopupViewBackgroundType_Blur];
142 | [keyWindow addSubview:popView];
143 |
144 | return popView;
145 | }
146 |
147 | + (instancetype)popupViewInView:(UIView *)view {
148 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:ZHPopupViewBackgroundType_SimpleOpacity];
149 |
150 | [view addSubview:popView];
151 |
152 | return popView;
153 | }
154 |
155 | + (instancetype)popupBlurViewInView:(UIView *)view {
156 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:ZHPopupViewBackgroundType_Blur];
157 |
158 | [view addSubview:popView];
159 |
160 | return popView;
161 | }
162 |
163 |
164 | - (void)layoutSubviews {
165 | [super layoutSubviews];
166 |
167 |
168 | CGFloat previousYPos = kZHPopupView_HeadInterval;
169 | CGRect frame;
170 | if (nil != _headIconImgView && nil != [_headIconImgView superview] && nil != _headIconImg) {
171 |
172 | frame = _headIconImgView.frame;
173 | frame.origin.y = kZHPopupView_HeadInterval;
174 | [_headIconImgView setFrame:frame];
175 | previousYPos = CGRectGetMaxY(_headIconImgView.frame);
176 | }
177 |
178 | if (nil != _headTitleLbl && nil != [_headTitleLbl superview]) {
179 | frame = _headTitleLbl.frame;
180 | if (nil == _headTitleLbl.text || _headTitleLbl.text.length <= 0) {
181 | //hide by height
182 | frame.size.height = 0.0f;
183 | } else {
184 | CGSize textSize = [_headTitleLbl.text sizeWithAttributes:@{
185 | NSFontAttributeName : _headTitleLbl.font
186 | }];
187 |
188 | frame.size.height = textSize.height;
189 | }
190 | frame.origin.y = previousYPos + 20.0f;
191 | [_headTitleLbl setFrame:frame];
192 | previousYPos = CGRectGetMaxY(_headTitleLbl.frame);
193 | }
194 |
195 | [_contentTextView sizeToFit];
196 | frame = _contentTextView.frame;
197 | frame.origin.y = previousYPos + 25.0f;
198 | [_contentTextView setFrame:frame];
199 | [_contentTextView setTextContainerInset:UIEdgeInsetsZero];
200 |
201 | //again adjust frame
202 |
203 | if (_contentTextView.text.length <= 0) {
204 | //there's no content displaying,need to trim the space
205 |
206 | frame = _headTitleLbl.frame;
207 | frame.origin.y = self.container.frame.size.height - kZHPopupView_buttonDefaultHeight - 25.0f - _headTitleLbl.frame.size.height;
208 | [_headTitleLbl setFrame:frame];
209 |
210 | frame = self.container.frame;
211 | frame.size.height = frame.size.height - CGRectGetMinY(_headTitleLbl.frame) + 20.0f;
212 | frame.origin.y = self.frame.size.height / 2 - frame.size.height / 2;
213 | [self.container setFrame:frame];
214 | } else {
215 |
216 | //adjust button Area
217 |
218 | if (nil != _buttonArea) {
219 | frame = _buttonArea.frame;
220 | frame.origin.y = CGRectGetMaxY(_contentTextView.frame) + 25.0f;
221 | [_buttonArea setFrame:frame];
222 | }
223 |
224 |
225 | frame = self.container.frame;
226 | frame.size.height = CGRectGetMaxY(_buttonArea.frame);
227 | frame.origin.y = self.frame.size.height / 2 - frame.size.height / 2;
228 | [self.container setFrame:frame];
229 | }
230 |
231 | //check on container height
232 |
233 |
234 | if(self.container.frame.size.height >= kScreen_Height) {
235 | frame = self.container.frame;
236 | frame.size.height = kScreen_Height - 40.0f;
237 | frame.origin.y = self.frame.size.height /2 - frame.size.height/2;
238 | [self.container setFrame:frame];
239 |
240 | //adjust buttons and contents
241 |
242 |
243 | CGFloat accrodingYPos = self.container.frame.size.height;
244 | if(nil!=_buttonArea && nil!=_buttonArea.superview) {
245 | frame = _buttonArea.frame;
246 | frame.origin.y = self.container.frame.size.height - frame.size.height;
247 | [_buttonArea setFrame:frame];
248 | accrodingYPos = CGRectGetMinY(_buttonArea.frame);
249 | }
250 |
251 |
252 | frame = _contentTextView.frame;
253 | if(CGRectGetMaxY(frame)>=accrodingYPos) {
254 | frame.size.height = accrodingYPos - frame.origin.y - 35.0f;
255 | [_contentTextView setFrame:frame];
256 |
257 | }
258 | }
259 |
260 |
261 | }
262 |
263 | + (instancetype)popUpDialogWithCustomFontViewInView:(UIView *)view iconImg:(UIImage *)iconImg backgroundStyle:(ZHPopupViewBackgroundType)backgroundType title:(NSString *)title titleFont:(UIFont *)titleFont content:(NSString *)content contentFont:(UIFont *)contentFont buttonTitles:(NSArray *)titles confirmBtnTextColor:(UIColor *)confirmBtnTextColor confirmTitleFont:(UIFont *)confirmTitleFont otherBtnTextColor:(UIColor *)otherBtnTextColor otherBtnFont:(UIFont *)otherBtnFont buttonPressedBlock:(void (^)(NSInteger))buttonPressedBlock {
264 | view = (nil == view) ?[UIApplication sharedApplication].keyWindow : view;
265 | ZHPopupView *popView = [[ZHPopupView alloc] initPopUpViewInView:view backgroundType:backgroundType];
266 |
267 |
268 | [view addSubview:popView];
269 |
270 | [popView setHeadIconImg:iconImg];
271 |
272 | [popView setHeadTitle:(nil == title) ? @"" : title];
273 |
274 | // Customize title font
275 | if (titleFont) {
276 | [popView setHeadTitleFont:titleFont];
277 | }
278 |
279 | [popView setContent:(nil == content) ? @"" : content];
280 |
281 | // Customize content font
282 | if (contentFont) {
283 | [popView setContentTextFont:contentFont];
284 | }
285 |
286 | [popView configureButtonWithTitles:titles confirmTitleColor:confirmBtnTextColor confirmTitleFont:confirmTitleFont otherTitleColor:otherBtnTextColor otherTitleFont:otherBtnFont];
287 |
288 | [popView setButtonPressedBlock:buttonPressedBlock];
289 |
290 |
291 | return popView;
292 | }
293 |
294 | #pragma mark - Initialization
295 |
296 | - (void)_initialization {
297 | [self _createView];
298 | }
299 |
300 | #pragma mark - Events
301 |
302 | - (void)pressedOnTitleButton:(UIButton *)sender {
303 |
304 | NSInteger idx = sender.tag - 233;
305 |
306 | [self disappear];
307 |
308 | if (nil != self.buttonPressedBlock) {
309 | self.buttonPressedBlock(idx);
310 | }
311 |
312 |
313 | }
314 |
315 | - (void)configureButtonWithTitles:(NSArray *)titles confirmTitleColor:(UIColor *)confirmTitleColor otherTitleColor:(UIColor *)otherTitleColor {
316 | if (nil == titles || titles.count <= 0) {
317 | if(nil!=[self.buttonArea superview]) {
318 | [self.buttonArea removeFromSuperview];
319 | }
320 | return;
321 | }
322 |
323 | [[self.buttonArea subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *_Nonnull stop) {
324 | [obj removeFromSuperview];
325 | }];
326 |
327 |
328 | confirmTitleColor = (nil == confirmTitleColor) ? COLOR_MAINBLUE : confirmTitleColor;
329 | otherTitleColor = (nil == otherTitleColor) ? COLOR_333333 : otherTitleColor;
330 |
331 | __block CGFloat perWidth = self.container.frame.size.width / titles.count;
332 |
333 | [titles enumerateObjectsUsingBlock:^(NSString *title, NSUInteger idx, BOOL *stop) {
334 | if (nil == title || title.length <= 0) {
335 | return;
336 | }
337 |
338 | UIButton *btn = [self buttonWithTitle:title textColor:(idx == titles.count - 1) ? confirmTitleColor : otherTitleColor width:perWidth xPos:idx * perWidth yPos:0];
339 | [btn setTag:idx + 233];
340 | [btn addTarget:self action:@selector(pressedOnTitleButton:) forControlEvents:UIControlEventTouchUpInside];
341 | [self.buttonArea addSubview:btn];
342 |
343 | if (idx != titles.count - 1) {
344 | UIView *seperator = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame), CGRectGetMinY(btn.frame), 0.5f, btn.frame.size.height)];
345 | [seperator setBackgroundColor:COLOR_E5E5E5];
346 | [self.buttonArea addSubview:seperator];
347 | }
348 |
349 | }];
350 |
351 | UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.container.frame.size.width, 0.5f)];
352 | [line setBackgroundColor:COLOR_E5E5E5];
353 | [self.buttonArea addSubview:line];
354 |
355 | if (nil == [self.buttonArea superview]) {
356 | [self.container addSubview:self.buttonArea];
357 | }
358 |
359 | [self layoutSubviews];
360 |
361 | }
362 |
363 | - (void)configureButtonWithTitles:(NSArray *)titles confirmTitleColor:(UIColor *)confirmTitleColor confirmTitleFont:(UIFont *)confirmTitleFont otherTitleColor:(UIColor *)otherTitleColor otherTitleFont:(UIFont *)otherTitleFont {
364 | if (nil == titles || titles.count <= 0) {
365 | if(nil!=[self.buttonArea superview]) {
366 | [self.buttonArea removeFromSuperview];
367 | }
368 | return;
369 | }
370 |
371 | [[self.buttonArea subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *_Nonnull stop) {
372 | [obj removeFromSuperview];
373 | }];
374 |
375 |
376 | confirmTitleColor = (nil == confirmTitleColor) ? COLOR_MAINBLUE : confirmTitleColor;
377 | otherTitleColor = (nil == otherTitleColor) ? COLOR_333333 : otherTitleColor;
378 |
379 | __block CGFloat perWidth = self.container.frame.size.width / titles.count;
380 |
381 | [titles enumerateObjectsUsingBlock:^(NSString *title, NSUInteger idx, BOOL *stop) {
382 | if (nil == title || title.length <= 0) {
383 | return;
384 | }
385 |
386 | UIButton *btn = [self buttonWithTitle:title textColor:(idx == titles.count - 1) ? confirmTitleColor : otherTitleColor width:perWidth xPos:idx * perWidth yPos:0];
387 | [btn setTag:idx + 233];
388 | [btn addTarget:self action:@selector(pressedOnTitleButton:) forControlEvents:UIControlEventTouchUpInside];
389 | [self.buttonArea addSubview:btn];
390 |
391 | // Add font custom in buttons
392 | if (confirmTitleFont && idx == titles.count - 1) {
393 | btn.titleLabel.font = confirmTitleFont;
394 | } else if (otherTitleFont && idx != titles.count - 1) {
395 | btn.titleLabel.font = otherTitleFont;
396 | }
397 |
398 | if (idx != titles.count - 1) {
399 | UIView *seperator = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(btn.frame), CGRectGetMinY(btn.frame), 0.5f, btn.frame.size.height)];
400 | [seperator setBackgroundColor:COLOR_E5E5E5];
401 | [self.buttonArea addSubview:seperator];
402 | }
403 |
404 | }];
405 |
406 | UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.container.frame.size.width, 0.5f)];
407 | [line setBackgroundColor:COLOR_E5E5E5];
408 | [self.buttonArea addSubview:line];
409 |
410 | if (nil == [self.buttonArea superview]) {
411 | [self.container addSubview:self.buttonArea];
412 | }
413 |
414 | [self layoutSubviews];
415 |
416 | }
417 |
418 | - (UIButton *)buttonWithTitle:(NSString *)title textColor:(UIColor *)textColor width:(CGFloat)width xPos:(CGFloat)xPos yPos:(CGFloat)yPos {
419 |
420 | UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(xPos, yPos, width, 40.0f)];
421 |
422 | [button setTitleColor:textColor forState:UIControlStateNormal];
423 | [button setTitle:title forState:UIControlStateNormal];
424 | [button.titleLabel setFont:[UIFont systemFontOfSize:14.0f]];
425 |
426 |
427 | return button;
428 | }
429 |
430 | #pragma mark - Properties
431 |
432 |
433 | - (void)setHeadTextAlignment:(NSTextAlignment)headTextAlignment {
434 | _headTextAlignment = headTextAlignment;
435 |
436 | [self.headTitleLbl setTextAlignment:headTextAlignment];
437 |
438 | }
439 |
440 | - (void)setContentTextAlignment:(NSTextAlignment)contentTextAlignment {
441 | _contentTextAlignment = contentTextAlignment;
442 |
443 | [self.contentTextView setTextAlignment:contentTextAlignment];
444 | }
445 |
446 | - (void)setHeadTitleFont:(UIFont *)headTitleFont {
447 | _headTitleFont = headTitleFont;
448 |
449 | [self.headTitleLbl setFont:headTitleFont];
450 |
451 | [self layoutSubviews];
452 | }
453 |
454 | - (void)setHeadTitleFontSize:(CGFloat)headTitleFontSize {
455 | _headTitleFontSize = headTitleFontSize;
456 |
457 | [self.headTitleLbl setFont:[UIFont systemFontOfSize:headTitleFontSize]];
458 |
459 | [self layoutSubviews];
460 | }
461 |
462 | - (void)setContentTextFontSize:(CGFloat)contentTextFontSize {
463 | _contentTextFontSize = contentTextFontSize;
464 | [self.contentTextView setFont:[UIFont systemFontOfSize:contentTextFontSize]];
465 | [self layoutSubviews];
466 | }
467 |
468 |
469 | - (void)setHeadTitleColor:(UIColor *)headTitleColor {
470 | _headTitleColor = headTitleColor;
471 |
472 | [self.headTitleLbl setTextColor:_headTitleColor];
473 | }
474 |
475 | - (void)setContentTextColor:(UIColor *)contentTextColor {
476 | _contentTextColor = contentTextColor;
477 |
478 | [self.contentTextView setTextColor:contentTextColor];
479 | }
480 |
481 | - (void)setHeadIconImg:(UIImage *)headIconImg {
482 | _headIconImg = headIconImg;
483 | [self.headIconImgView setImage:headIconImg];
484 | if (nil == [self.headIconImgView superview]) {
485 | [self.container addSubview:self.headIconImgView];
486 | }
487 | [self layoutSubviews];
488 | }
489 |
490 | - (void)setHeadTitle:(NSString *)headTitle {
491 |
492 | _headTitle = headTitle;
493 | [self.headTitleLbl setText:headTitle];
494 | if (nil == [self.headTitleLbl superview]) {
495 | [self.container addSubview:self.headTitleLbl];
496 | }
497 |
498 | [self layoutSubviews];
499 | }
500 |
501 | - (void)setContent:(NSString *)content {
502 |
503 | _content = content;
504 | [self.contentTextView setText:content];
505 | if (nil == [self.contentTextView superview]) {
506 | [self.container addSubview:self.contentTextView];
507 | }
508 |
509 | [self layoutSubviews];
510 | }
511 |
512 | - (UIView *)buttonArea {
513 | if (nil == _buttonArea) {
514 |
515 | _buttonArea = [[UIView alloc] initWithFrame:CGRectMake(0, self.container.frame.size.height - kZHPopupView_buttonDefaultHeight, self.container.frame.size.width, kZHPopupView_buttonDefaultHeight)];
516 |
517 | }
518 | return _buttonArea;
519 | }
520 |
521 | -(void)setContentTextFont:(UIFont *)contentTextFont {
522 | _contentTextFont = contentTextFont;
523 |
524 | _contentTextView.font = contentTextFont;
525 | }
526 |
527 | - (UIImageView *)headIconImgView {
528 | if (nil == _headIconImgView) {
529 | _headIconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.container.frame.size.width / 2 - 17.5f, kZHPopupView_HeadInterval, 35.0f, 35.0f)];
530 | [_headIconImgView setContentMode:UIViewContentModeScaleAspectFit];
531 | }
532 | return _headIconImgView;
533 | }
534 |
535 | - (UILabel *)headTitleLbl {
536 | if (nil == _headTitleLbl) {
537 | _headTitleLbl = [[UILabel alloc] initWithFrame:CGRectMake(kZHPopupView_InsideLeftInterval, 0.0f, self.container.frame.size.width - 2 * kZHPopupView_InsideLeftInterval, 20.0f)];
538 | [_headTitleLbl setTextColor:[UIColor darkTextColor]];
539 | [_headTitleLbl setFont:[UIFont systemFontOfSize:20.0f]];
540 | [_headTitleLbl setTextAlignment:NSTextAlignmentCenter];
541 |
542 | }
543 | return _headTitleLbl;
544 | }
545 |
546 | - (UITextView *)contentTextView {
547 | if (nil == _contentTextView) {
548 | _contentTextView = [[UITextView alloc] initWithFrame:CGRectMake(kZHPopupView_InsideLeftInterval, 0.0f, self.container.frame.size.width - 2 * kZHPopupView_InsideLeftInterval, 20.0f)];
549 | [_contentTextView setTextColor:[UIColor darkTextColor]];
550 | [_contentTextView setFont:[UIFont systemFontOfSize:14.0f]];
551 | [_contentTextView setBackgroundColor:[UIColor clearColor]];
552 | [_contentTextView setUserInteractionEnabled:NO];
553 | [_contentTextView setScrollEnabled:NO];
554 | [_contentTextView setEditable:NO];
555 | }
556 | return _contentTextView;
557 | }
558 |
559 | - (UIView *)container {
560 | if (nil == _container) {
561 |
562 | CGFloat xPos = kZHPopupViewContainerLeftRightInterval;
563 | CGFloat yPos = ((nil != self.parentView) ? self.parentView.bounds.size.height / 2 : kZHPopupView_ScreenHeight / 2) - kZHPopupViewContainerDefaultHeight / 2;
564 | CGFloat width = ((nil != self.parentView) ? self.parentView.bounds.size.width : kZHPopupView_ScreenWidth) - 2 * kZHPopupViewContainerLeftRightInterval;
565 | CGFloat height = kZHPopupViewContainerDefaultHeight;
566 |
567 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(xPos, yPos, width, height)];
568 | [view setBackgroundColor:[UIColor whiteColor]];
569 | [view.layer setCornerRadius:5.0f];
570 | [view.layer setMasksToBounds:YES];
571 |
572 | // [view dropShadowWithShadowColor:[UIColor colorWithWhite:0.0f alpha:0.8f] offset:CGSizeMake(0, 3.0f) opacity:0.5f radius:10.0f];
573 | _container = view;
574 | view = nil;
575 | }
576 |
577 | return _container;
578 | }
579 |
580 |
581 | #pragma mark - Display Event
582 |
583 |
584 | - (void)present {
585 |
586 | if (nil == self.parentView) {
587 | return;
588 | }
589 | if (nil == [self superview]) {
590 |
591 | [self.parentView addSubview:self];
592 | }
593 |
594 | [self.layer setOpacity:0.0f];
595 | [_container.layer setOpacity:0.0f];
596 |
597 |
598 | [UIView animateWithDuration:0.2f animations:^{
599 | [self.layer setOpacity:1.0f];
600 | [_container.layer setOpacity:1.0f];
601 | } completion:^(BOOL finished) {
602 |
603 |
604 | // CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
605 | //
606 |
607 | // animation.duration = 0.08f;
608 | // animation.autoreverses = YES;
609 | //
610 |
611 | // animation.fromValue = [NSNumber numberWithFloat:1.0f];
612 | // animation.toValue = [NSNumber numberWithFloat:1.03f];
613 | //
614 |
615 | // [_container.layer addAnimation:animation forKey:@"scale-layer"];
616 |
617 | }];
618 |
619 | }
620 |
621 | - (void)disappear {
622 |
623 | [UIView animateWithDuration:0.1f animations:^{
624 | [self.layer setOpacity:0.0f];
625 | } completion:^(BOOL finished) {
626 | [self removeFromSuperview];
627 | }];
628 |
629 | }
630 |
631 | #pragma mark - Background Gesture
632 |
633 | - (void)tappedOnBackground:(UITapGestureRecognizer *)tapGesture {
634 |
635 | CGPoint location = [tapGesture locationInView:self];
636 | if (CGRectContainsPoint(self.container.frame, location)) {
637 | return;
638 | }
639 | [self disappear];
640 | }
641 |
642 | #pragma mark - View
643 |
644 |
645 | - (void)_configureBackgroundBlur {
646 | //structure view
647 | UIGraphicsBeginImageContext(self.parentView.frame.size);
648 | CGContextRef context = UIGraphicsGetCurrentContext();
649 | [self.parentView.layer renderInContext:context];
650 | UIImage *clipImg = UIGraphicsGetImageFromCurrentImageContext();
651 | UIGraphicsEndImageContext();
652 |
653 |
654 | UIColor *tintColor = [UIColor colorWithWhite:0.10 alpha:0.3];
655 |
656 | UIImage *blurImg = [UIImageEffects imageByApplyingBlurToImage:clipImg withRadius:10 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
657 | UIImageView *bgImgView = [[UIImageView alloc] initWithImage:blurImg];
658 |
659 | [self addSubview:bgImgView];
660 |
661 |
662 | }
663 |
664 | - (void)_createView {
665 |
666 | [self.layer setOpacity:0.0f];
667 |
668 | if (self.backgroundType == ZHPopupViewBackgroundType_SimpleOpacity) {
669 | self.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.5f];
670 | } else {
671 | [self _configureBackgroundBlur];
672 | }
673 |
674 |
675 | [self addSubview:[self container]];
676 |
677 | //Tap gesture
678 |
679 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tappedOnBackground:)];
680 | [self addGestureRecognizer:tapGesture];
681 |
682 |
683 | }
684 | @end
685 |
--------------------------------------------------------------------------------
/ZHPopupView/comic-sans.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhhlmr/ZHPopupView/694d445ec83d38914ae98db12c8ed21b90aac677/ZHPopupView/comic-sans.ttf
--------------------------------------------------------------------------------
/ZHPopupView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ZHPopupView
4 | //
5 | // Created by heyz3a on 16/4/26.
6 | // Copyright © 2016年 heyz3a. 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 |
--------------------------------------------------------------------------------
/_Pods.xcodeproj:
--------------------------------------------------------------------------------
1 | Example/Pods/Pods.xcodeproj
--------------------------------------------------------------------------------
/screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhhlmr/ZHPopupView/694d445ec83d38914ae98db12c8ed21b90aac677/screen.png
--------------------------------------------------------------------------------