├── AlertViewDemo ├── AlertViewDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── ZBB.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── ZBB.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── AlertViewDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Class │ │ ├── BBAlertView.h │ │ └── BBAlertView.m │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── AlertViewDemoUITests │ ├── AlertViewDemoUITests.m │ └── Info.plist ├── MBProgressHUD封装后直接调用 ├── MBProgressHUD封装后直接调用.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── ZBB.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── ZBB.xcuserdatad │ │ └── xcschemes │ │ ├── MBProgressHUD封装后直接调用.xcscheme │ │ └── xcschememanagement.plist ├── MBProgressHUD封装后直接调用.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── ZBB.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist ├── MBProgressHUD封装后直接调用 │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Class │ │ ├── MBHUD.h │ │ ├── MBHUD.m │ │ ├── NSObject+MBProgressHUD.h │ │ ├── NSObject+MBProgressHUD.m │ │ ├── UIViewController+MBProgressHUD.h │ │ └── UIViewController+MBProgressHUD.m │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── MBProgressHUD封装后直接调用Tests │ ├── Info.plist │ └── MBProgressHUD_______Tests.m ├── MBProgressHUD封装后直接调用UITests │ ├── Info.plist │ └── MBProgressHUD_______UITests.m ├── PodFile ├── Podfile.lock └── Pods │ ├── Headers │ ├── Private │ │ └── MBProgressHUD │ │ │ └── MBProgressHUD.h │ └── Public │ │ └── MBProgressHUD │ │ └── MBProgressHUD.h │ ├── MBProgressHUD │ ├── LICENSE │ ├── MBProgressHUD.h │ ├── MBProgressHUD.m │ └── README.mdown │ ├── Manifest.lock │ ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── ZBB.xcuserdatad │ │ └── xcschemes │ │ ├── MBProgressHUD.xcscheme │ │ ├── Pods-MBProgressHUD封装后直接调用.xcscheme │ │ └── xcschememanagement.plist │ └── Target Support Files │ ├── MBProgressHUD │ ├── MBProgressHUD-dummy.m │ ├── MBProgressHUD-prefix.pch │ └── MBProgressHUD.xcconfig │ └── Pods-MBProgressHUD封装后直接调用 │ ├── Pods-MBProgressHUD封装后直接调用-acknowledgements.markdown │ ├── Pods-MBProgressHUD封装后直接调用-acknowledgements.plist │ ├── Pods-MBProgressHUD封装后直接调用-dummy.m │ ├── Pods-MBProgressHUD封装后直接调用-frameworks.sh │ ├── Pods-MBProgressHUD封装后直接调用-resources.sh │ ├── Pods-MBProgressHUD封装后直接调用.debug.xcconfig │ └── Pods-MBProgressHUD封装后直接调用.release.xcconfig ├── PageViewControllerDemo ├── PageViewControllerDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── ZBB.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── ZBB.xcuserdatad │ │ └── xcschemes │ │ ├── PageViewControllerDemo.xcscheme │ │ └── xcschememanagement.plist ├── PageViewControllerDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Base │ │ ├── HMSegmentedControl.h │ │ └── HMSegmentedControl.m │ ├── BasePageViewController.h │ ├── BasePageViewController.m │ ├── BaseViewController.h │ ├── BaseViewController.m │ ├── CommonPageViewController.h │ ├── CommonPageViewController.m │ ├── FirstController.h │ ├── FirstController.m │ ├── Info.plist │ ├── SecondController.h │ ├── SecondController.m │ ├── ThirdController.h │ ├── ThirdController.m │ └── main.m ├── PageViewControllerDemoTests │ ├── Info.plist │ └── PageViewControllerDemoTests.m └── PageViewControllerDemoUITests │ ├── Info.plist │ └── PageViewControllerDemoUITests.m ├── README.md └── TopViewDemo ├── TopViewDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── ZBB.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── ZBB.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── TopViewDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Class │ ├── BBTopView.h │ ├── BBTopView.m │ └── fontawesome │ │ ├── FAImageView.h │ │ ├── FAImageView.m │ │ ├── FontAwesome.ttf │ │ ├── NSString+FontAwesome.h │ │ ├── NSString+FontAwesome.m │ │ ├── UIFont+FontAwesome.h │ │ └── UIFont+FontAwesome.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m └── TopViewDemoUITests ├── Info.plist └── TopViewDemoUITests.m /AlertViewDemo/AlertViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3D43AFFD1F95F6F80009E0A7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D43AFFC1F95F6F80009E0A7 /* AppDelegate.m */; }; 11 | 3D43B0001F95F6F80009E0A7 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D43AFFF1F95F6F80009E0A7 /* ViewController.m */; }; 12 | 3D43B0031F95F6F80009E0A7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D43B0011F95F6F80009E0A7 /* Main.storyboard */; }; 13 | 3D43B0051F95F6F80009E0A7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D43B0041F95F6F80009E0A7 /* Assets.xcassets */; }; 14 | 3D43B0081F95F6F80009E0A7 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D43B0061F95F6F80009E0A7 /* LaunchScreen.storyboard */; }; 15 | 3D43B00B1F95F6F80009E0A7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D43B00A1F95F6F80009E0A7 /* main.m */; }; 16 | 3D43B0151F95F6F80009E0A7 /* AlertViewDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D43B0141F95F6F80009E0A7 /* AlertViewDemoUITests.m */; }; 17 | 3D43B0221F95F72B0009E0A7 /* BBAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D43B0211F95F72B0009E0A7 /* BBAlertView.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 3D43B0111F95F6F80009E0A7 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 3D43AFF01F95F6F80009E0A7 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 3D43AFF71F95F6F80009E0A7; 26 | remoteInfo = AlertViewDemo; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 3D43AFF81F95F6F80009E0A7 /* AlertViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AlertViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 3D43AFFB1F95F6F80009E0A7 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 33 | 3D43AFFC1F95F6F80009E0A7 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 34 | 3D43AFFE1F95F6F80009E0A7 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 35 | 3D43AFFF1F95F6F80009E0A7 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 36 | 3D43B0021F95F6F80009E0A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | 3D43B0041F95F6F80009E0A7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 38 | 3D43B0071F95F6F80009E0A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 39 | 3D43B0091F95F6F80009E0A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | 3D43B00A1F95F6F80009E0A7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 3D43B0101F95F6F80009E0A7 /* AlertViewDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AlertViewDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 3D43B0141F95F6F80009E0A7 /* AlertViewDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AlertViewDemoUITests.m; sourceTree = ""; }; 43 | 3D43B0161F95F6F80009E0A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 3D43B0201F95F72B0009E0A7 /* BBAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BBAlertView.h; sourceTree = ""; }; 45 | 3D43B0211F95F72B0009E0A7 /* BBAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BBAlertView.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 3D43AFF51F95F6F80009E0A7 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | 3D43B00D1F95F6F80009E0A7 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 3D43AFEF1F95F6F80009E0A7 = { 67 | isa = PBXGroup; 68 | children = ( 69 | 3D43AFFA1F95F6F80009E0A7 /* AlertViewDemo */, 70 | 3D43B0131F95F6F80009E0A7 /* AlertViewDemoUITests */, 71 | 3D43AFF91F95F6F80009E0A7 /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | 3D43AFF91F95F6F80009E0A7 /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 3D43AFF81F95F6F80009E0A7 /* AlertViewDemo.app */, 79 | 3D43B0101F95F6F80009E0A7 /* AlertViewDemoUITests.xctest */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | 3D43AFFA1F95F6F80009E0A7 /* AlertViewDemo */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 3D43B01F1F95F7120009E0A7 /* Class */, 88 | 3D43AFFB1F95F6F80009E0A7 /* AppDelegate.h */, 89 | 3D43AFFC1F95F6F80009E0A7 /* AppDelegate.m */, 90 | 3D43AFFE1F95F6F80009E0A7 /* ViewController.h */, 91 | 3D43AFFF1F95F6F80009E0A7 /* ViewController.m */, 92 | 3D43B0011F95F6F80009E0A7 /* Main.storyboard */, 93 | 3D43B0041F95F6F80009E0A7 /* Assets.xcassets */, 94 | 3D43B0061F95F6F80009E0A7 /* LaunchScreen.storyboard */, 95 | 3D43B0091F95F6F80009E0A7 /* Info.plist */, 96 | 3D43B00A1F95F6F80009E0A7 /* main.m */, 97 | ); 98 | path = AlertViewDemo; 99 | sourceTree = ""; 100 | }; 101 | 3D43B0131F95F6F80009E0A7 /* AlertViewDemoUITests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 3D43B0141F95F6F80009E0A7 /* AlertViewDemoUITests.m */, 105 | 3D43B0161F95F6F80009E0A7 /* Info.plist */, 106 | ); 107 | path = AlertViewDemoUITests; 108 | sourceTree = ""; 109 | }; 110 | 3D43B01F1F95F7120009E0A7 /* Class */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 3D43B0201F95F72B0009E0A7 /* BBAlertView.h */, 114 | 3D43B0211F95F72B0009E0A7 /* BBAlertView.m */, 115 | ); 116 | path = Class; 117 | sourceTree = ""; 118 | }; 119 | /* End PBXGroup section */ 120 | 121 | /* Begin PBXNativeTarget section */ 122 | 3D43AFF71F95F6F80009E0A7 /* AlertViewDemo */ = { 123 | isa = PBXNativeTarget; 124 | buildConfigurationList = 3D43B0191F95F6F80009E0A7 /* Build configuration list for PBXNativeTarget "AlertViewDemo" */; 125 | buildPhases = ( 126 | 3D43AFF41F95F6F80009E0A7 /* Sources */, 127 | 3D43AFF51F95F6F80009E0A7 /* Frameworks */, 128 | 3D43AFF61F95F6F80009E0A7 /* Resources */, 129 | ); 130 | buildRules = ( 131 | ); 132 | dependencies = ( 133 | ); 134 | name = AlertViewDemo; 135 | productName = AlertViewDemo; 136 | productReference = 3D43AFF81F95F6F80009E0A7 /* AlertViewDemo.app */; 137 | productType = "com.apple.product-type.application"; 138 | }; 139 | 3D43B00F1F95F6F80009E0A7 /* AlertViewDemoUITests */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = 3D43B01C1F95F6F80009E0A7 /* Build configuration list for PBXNativeTarget "AlertViewDemoUITests" */; 142 | buildPhases = ( 143 | 3D43B00C1F95F6F80009E0A7 /* Sources */, 144 | 3D43B00D1F95F6F80009E0A7 /* Frameworks */, 145 | 3D43B00E1F95F6F80009E0A7 /* Resources */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | 3D43B0121F95F6F80009E0A7 /* PBXTargetDependency */, 151 | ); 152 | name = AlertViewDemoUITests; 153 | productName = AlertViewDemoUITests; 154 | productReference = 3D43B0101F95F6F80009E0A7 /* AlertViewDemoUITests.xctest */; 155 | productType = "com.apple.product-type.bundle.ui-testing"; 156 | }; 157 | /* End PBXNativeTarget section */ 158 | 159 | /* Begin PBXProject section */ 160 | 3D43AFF01F95F6F80009E0A7 /* Project object */ = { 161 | isa = PBXProject; 162 | attributes = { 163 | LastUpgradeCheck = 0900; 164 | ORGANIZATIONNAME = BBFC; 165 | TargetAttributes = { 166 | 3D43AFF71F95F6F80009E0A7 = { 167 | CreatedOnToolsVersion = 9.0; 168 | ProvisioningStyle = Automatic; 169 | }; 170 | 3D43B00F1F95F6F80009E0A7 = { 171 | CreatedOnToolsVersion = 9.0; 172 | ProvisioningStyle = Automatic; 173 | TestTargetID = 3D43AFF71F95F6F80009E0A7; 174 | }; 175 | }; 176 | }; 177 | buildConfigurationList = 3D43AFF31F95F6F80009E0A7 /* Build configuration list for PBXProject "AlertViewDemo" */; 178 | compatibilityVersion = "Xcode 8.0"; 179 | developmentRegion = en; 180 | hasScannedForEncodings = 0; 181 | knownRegions = ( 182 | en, 183 | Base, 184 | ); 185 | mainGroup = 3D43AFEF1F95F6F80009E0A7; 186 | productRefGroup = 3D43AFF91F95F6F80009E0A7 /* Products */; 187 | projectDirPath = ""; 188 | projectRoot = ""; 189 | targets = ( 190 | 3D43AFF71F95F6F80009E0A7 /* AlertViewDemo */, 191 | 3D43B00F1F95F6F80009E0A7 /* AlertViewDemoUITests */, 192 | ); 193 | }; 194 | /* End PBXProject section */ 195 | 196 | /* Begin PBXResourcesBuildPhase section */ 197 | 3D43AFF61F95F6F80009E0A7 /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | 3D43B0081F95F6F80009E0A7 /* LaunchScreen.storyboard in Resources */, 202 | 3D43B0051F95F6F80009E0A7 /* Assets.xcassets in Resources */, 203 | 3D43B0031F95F6F80009E0A7 /* Main.storyboard in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | 3D43B00E1F95F6F80009E0A7 /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | /* End PBXResourcesBuildPhase section */ 215 | 216 | /* Begin PBXSourcesBuildPhase section */ 217 | 3D43AFF41F95F6F80009E0A7 /* Sources */ = { 218 | isa = PBXSourcesBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | 3D43B0001F95F6F80009E0A7 /* ViewController.m in Sources */, 222 | 3D43B00B1F95F6F80009E0A7 /* main.m in Sources */, 223 | 3D43AFFD1F95F6F80009E0A7 /* AppDelegate.m in Sources */, 224 | 3D43B0221F95F72B0009E0A7 /* BBAlertView.m in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | 3D43B00C1F95F6F80009E0A7 /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 3D43B0151F95F6F80009E0A7 /* AlertViewDemoUITests.m in Sources */, 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXSourcesBuildPhase section */ 237 | 238 | /* Begin PBXTargetDependency section */ 239 | 3D43B0121F95F6F80009E0A7 /* PBXTargetDependency */ = { 240 | isa = PBXTargetDependency; 241 | target = 3D43AFF71F95F6F80009E0A7 /* AlertViewDemo */; 242 | targetProxy = 3D43B0111F95F6F80009E0A7 /* PBXContainerItemProxy */; 243 | }; 244 | /* End PBXTargetDependency section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | 3D43B0011F95F6F80009E0A7 /* Main.storyboard */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 3D43B0021F95F6F80009E0A7 /* Base */, 251 | ); 252 | name = Main.storyboard; 253 | sourceTree = ""; 254 | }; 255 | 3D43B0061F95F6F80009E0A7 /* LaunchScreen.storyboard */ = { 256 | isa = PBXVariantGroup; 257 | children = ( 258 | 3D43B0071F95F6F80009E0A7 /* Base */, 259 | ); 260 | name = LaunchScreen.storyboard; 261 | sourceTree = ""; 262 | }; 263 | /* End PBXVariantGroup section */ 264 | 265 | /* Begin XCBuildConfiguration section */ 266 | 3D43B0171F95F6F80009E0A7 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ALWAYS_SEARCH_USER_PATHS = NO; 270 | CLANG_ANALYZER_NONNULL = YES; 271 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_MODULES = YES; 275 | CLANG_ENABLE_OBJC_ARC = YES; 276 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 277 | CLANG_WARN_BOOL_CONVERSION = YES; 278 | CLANG_WARN_COMMA = YES; 279 | CLANG_WARN_CONSTANT_CONVERSION = YES; 280 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 281 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 282 | CLANG_WARN_EMPTY_BODY = YES; 283 | CLANG_WARN_ENUM_CONVERSION = YES; 284 | CLANG_WARN_INFINITE_RECURSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 287 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 288 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 289 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 290 | CLANG_WARN_STRICT_PROTOTYPES = YES; 291 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 292 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 293 | CLANG_WARN_UNREACHABLE_CODE = YES; 294 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 295 | CODE_SIGN_IDENTITY = "iPhone Developer"; 296 | COPY_PHASE_STRIP = NO; 297 | DEBUG_INFORMATION_FORMAT = dwarf; 298 | ENABLE_STRICT_OBJC_MSGSEND = YES; 299 | ENABLE_TESTABILITY = YES; 300 | GCC_C_LANGUAGE_STANDARD = gnu11; 301 | GCC_DYNAMIC_NO_PIC = NO; 302 | GCC_NO_COMMON_BLOCKS = YES; 303 | GCC_OPTIMIZATION_LEVEL = 0; 304 | GCC_PREPROCESSOR_DEFINITIONS = ( 305 | "DEBUG=1", 306 | "$(inherited)", 307 | ); 308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_UNDECLARED_SELECTOR = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 312 | GCC_WARN_UNUSED_FUNCTION = YES; 313 | GCC_WARN_UNUSED_VARIABLE = YES; 314 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 315 | MTL_ENABLE_DEBUG_INFO = YES; 316 | ONLY_ACTIVE_ARCH = YES; 317 | SDKROOT = iphoneos; 318 | }; 319 | name = Debug; 320 | }; 321 | 3D43B0181F95F6F80009E0A7 /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_COMMA = YES; 334 | CLANG_WARN_CONSTANT_CONVERSION = YES; 335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 336 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 337 | CLANG_WARN_EMPTY_BODY = YES; 338 | CLANG_WARN_ENUM_CONVERSION = YES; 339 | CLANG_WARN_INFINITE_RECURSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 345 | CLANG_WARN_STRICT_PROTOTYPES = YES; 346 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 347 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 348 | CLANG_WARN_UNREACHABLE_CODE = YES; 349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 350 | CODE_SIGN_IDENTITY = "iPhone Developer"; 351 | COPY_PHASE_STRIP = NO; 352 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 353 | ENABLE_NS_ASSERTIONS = NO; 354 | ENABLE_STRICT_OBJC_MSGSEND = YES; 355 | GCC_C_LANGUAGE_STANDARD = gnu11; 356 | GCC_NO_COMMON_BLOCKS = YES; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 364 | MTL_ENABLE_DEBUG_INFO = NO; 365 | SDKROOT = iphoneos; 366 | VALIDATE_PRODUCT = YES; 367 | }; 368 | name = Release; 369 | }; 370 | 3D43B01A1F95F6F80009E0A7 /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 374 | CODE_SIGN_STYLE = Automatic; 375 | INFOPLIST_FILE = AlertViewDemo/Info.plist; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 377 | PRODUCT_BUNDLE_IDENTIFIER = ZBB.AlertViewDemo; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | TARGETED_DEVICE_FAMILY = "1,2"; 380 | }; 381 | name = Debug; 382 | }; 383 | 3D43B01B1F95F6F80009E0A7 /* Release */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 387 | CODE_SIGN_STYLE = Automatic; 388 | INFOPLIST_FILE = AlertViewDemo/Info.plist; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = ZBB.AlertViewDemo; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | TARGETED_DEVICE_FAMILY = "1,2"; 393 | }; 394 | name = Release; 395 | }; 396 | 3D43B01D1F95F6F80009E0A7 /* Debug */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | CODE_SIGN_STYLE = Automatic; 400 | INFOPLIST_FILE = AlertViewDemoUITests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = ZBB.AlertViewDemoUITests; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | TARGETED_DEVICE_FAMILY = "1,2"; 405 | TEST_TARGET_NAME = AlertViewDemo; 406 | }; 407 | name = Debug; 408 | }; 409 | 3D43B01E1F95F6F80009E0A7 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | CODE_SIGN_STYLE = Automatic; 413 | INFOPLIST_FILE = AlertViewDemoUITests/Info.plist; 414 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 415 | PRODUCT_BUNDLE_IDENTIFIER = ZBB.AlertViewDemoUITests; 416 | PRODUCT_NAME = "$(TARGET_NAME)"; 417 | TARGETED_DEVICE_FAMILY = "1,2"; 418 | TEST_TARGET_NAME = AlertViewDemo; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | 3D43AFF31F95F6F80009E0A7 /* Build configuration list for PBXProject "AlertViewDemo" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 3D43B0171F95F6F80009E0A7 /* Debug */, 429 | 3D43B0181F95F6F80009E0A7 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | 3D43B0191F95F6F80009E0A7 /* Build configuration list for PBXNativeTarget "AlertViewDemo" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 3D43B01A1F95F6F80009E0A7 /* Debug */, 438 | 3D43B01B1F95F6F80009E0A7 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | 3D43B01C1F95F6F80009E0A7 /* Build configuration list for PBXNativeTarget "AlertViewDemoUITests" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 3D43B01D1F95F6F80009E0A7 /* Debug */, 447 | 3D43B01E1F95F6F80009E0A7 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | /* End XCConfigurationList section */ 453 | }; 454 | rootObject = 3D43AFF01F95F6F80009E0A7 /* Project object */; 455 | } 456 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kazamihayato/iOS-CustomControl/0ba00e5d7e134ab09c1063163a92d217a7cbce72/AlertViewDemo/AlertViewDemo.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AlertViewDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. 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 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. 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 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/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 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/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 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/Class/BBAlertView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BBAlertView.h 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BBAlertView : UIView 12 | //确认弹框 13 | +(void) showAlertViewWithTitle:(NSString *)title 14 | message:(NSString *)message 15 | buttonTitles:(NSArray *)btnArr 16 | confirmBlock:(dispatch_block_t)confirmBlock; 17 | 18 | /** 19 | 左、右点击事件 20 | 21 | @param title 标题描述 22 | @param message 信息描述 23 | @param btnArray 按钮title数组(1-2个) 24 | @param leftBlock 左点击事件 25 | @param rightBlock 右点击事件 26 | */ 27 | +(void) showAlertViewWithTitle:(NSString*)title 28 | message:(NSString*)message 29 | buttonTitles:(NSArray*)btnArr 30 | leftBlock:(dispatch_block_t)leftBlock 31 | rightBlock:(dispatch_block_t)rightBlock; 32 | @end 33 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/Class/BBAlertView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BBAlertView.m 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BBAlertView.h" 10 | 11 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 12 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 13 | #define RGB(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(1.0)] 14 | 15 | const CGFloat AlertWidth = 270.0; 16 | const CGFloat AlertGap = 10.0; 17 | const CGFloat BtnHeight = 45.0; 18 | const CGFloat BtnWidth = 135.0; 19 | 20 | @interface BBAlertView () 21 | @property(nonatomic, copy )NSString * title; 22 | @property(nonatomic, copy )NSString * message; 23 | @property(nonatomic,strong)NSArray * btnArr; 24 | @property(nonatomic, copy )dispatch_block_t leftBlock; 25 | @property(nonatomic, copy )dispatch_block_t rightBlock; 26 | 27 | @property(nonatomic,strong)UIView * bgView; 28 | @property(nonatomic,strong)UIView * contentView; 29 | 30 | @end 31 | 32 | 33 | @implementation BBAlertView 34 | 35 | +(void) showAlertViewWithTitle:(NSString *)title 36 | message:(NSString *)message 37 | buttonTitles:(NSArray *)btnArr 38 | confirmBlock:(dispatch_block_t)confirmBlock 39 | { 40 | [BBAlertView showAlertViewWithTitle:title message:message buttonTitles:btnArr leftBlock:nil rightBlock:confirmBlock]; 41 | } 42 | 43 | +(void) showAlertViewWithTitle:(NSString*)title 44 | message:(NSString*)message 45 | buttonTitles:(NSArray*)btnArr 46 | leftBlock:(dispatch_block_t)leftBlock 47 | rightBlock:(dispatch_block_t)rightBlock 48 | { 49 | BBAlertView * alertView=[[BBAlertView alloc] initAlertViewWithTitle:title message:message buttonTitles:btnArr leftBlock:leftBlock rightBlock:rightBlock]; 50 | [alertView show]; 51 | } 52 | 53 | -(instancetype)initAlertViewWithTitle:(NSString*)title 54 | message:(NSString*)message 55 | buttonTitles:(NSArray*)btnArray 56 | leftBlock:(dispatch_block_t)leftBlock 57 | rightBlock:(dispatch_block_t)rightBlock 58 | { 59 | self=[super initWithFrame:[UIScreen mainScreen].bounds]; 60 | if (self) { 61 | _title = [title copy]; 62 | _message = [message copy]; 63 | _btnArr = btnArray; 64 | _leftBlock = [leftBlock copy]; 65 | _rightBlock = [rightBlock copy]; 66 | 67 | [self addSubview:self.bgView]; 68 | [self addSubview:self.contentView]; 69 | } 70 | return self; 71 | } 72 | 73 | -(UIView*)bgView 74 | { 75 | if (!_bgView) { 76 | _bgView = [[UIView alloc] initWithFrame:self.bounds]; 77 | _bgView.backgroundColor = [UIColor blackColor]; 78 | _bgView.alpha = 0.0f; 79 | } 80 | return _bgView; 81 | } 82 | 83 | -(UIView*)contentView 84 | { 85 | if (!_contentView) { 86 | _contentView = [[UIView alloc]init]; 87 | _contentView.layer.cornerRadius = 5; 88 | _contentView.layer.masksToBounds = YES; 89 | _contentView.backgroundColor = [UIColor whiteColor]; 90 | 91 | CGFloat titleHeight = [self createTitle]; 92 | CGFloat messageHeight = [self createMessageWithTitleHeight:titleHeight]; 93 | CGFloat btnHeight = [self createBtnWithMessageHeight:messageHeight]; 94 | 95 | _contentView.frame = CGRectMake((SCREEN_WIDTH-AlertWidth)/2, (SCREEN_HEIGHT-btnHeight)/2, AlertWidth, btnHeight); 96 | } 97 | return _contentView; 98 | } 99 | 100 | -(CGFloat)createTitle 101 | { 102 | if (_title==NULL) { 103 | return 0; 104 | } 105 | CGFloat height = [self heightWithString:_title fontSize:17 width:AlertWidth-2*AlertGap]; 106 | 107 | UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(AlertGap, AlertGap,AlertWidth-2*AlertGap,height)]; 108 | titleLabel.text = self.title; 109 | titleLabel.textColor = RGB(28, 28, 28); 110 | titleLabel.font = [UIFont systemFontOfSize:14]; 111 | titleLabel.textAlignment = NSTextAlignmentCenter; 112 | [self.contentView addSubview:titleLabel]; 113 | 114 | return CGRectGetMaxY(titleLabel.frame); 115 | } 116 | 117 | -(CGFloat)createMessageWithTitleHeight:(CGFloat)titleHeight 118 | { 119 | if (_message==NULL) { 120 | return 0; 121 | } 122 | CGFloat y= self.title.length==0?20.0:0.0; 123 | 124 | CGFloat height = [self heightWithString:_message fontSize:14 width:AlertWidth-2*AlertGap]; 125 | UILabel * messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(AlertGap, y+AlertGap+titleHeight, AlertWidth-2*AlertGap, height)]; 126 | messageLabel.numberOfLines = 0; 127 | messageLabel.text = _message; 128 | messageLabel.textColor = RGB(28, 28, 28); 129 | messageLabel.font = [UIFont systemFontOfSize:14]; 130 | messageLabel.textAlignment = NSTextAlignmentCenter; 131 | 132 | [self.contentView addSubview:messageLabel]; 133 | 134 | return CGRectGetMaxY(messageLabel.frame)+AlertGap+y; 135 | } 136 | 137 | -(CGFloat)createBtnWithMessageHeight:(CGFloat)messageHeight 138 | { 139 | UIView * btnView = [[UIView alloc] initWithFrame:CGRectMake(0, messageHeight+AlertGap, AlertWidth, BtnHeight)]; 140 | [self.contentView addSubview:btnView]; 141 | 142 | 143 | [self.btnArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 144 | UIButton*btn =[UIButton buttonWithType:UIButtonTypeCustom]; 145 | btn.frame =CGRectMake(BtnWidth*idx,0,self.btnArr.count==1?AlertWidth:BtnWidth, BtnHeight); 146 | btn.tag = 221+idx; 147 | btn.titleLabel.font = [UIFont systemFontOfSize:17]; 148 | btn.layer.borderColor =[UIColor lightGrayColor].CGColor; 149 | btn.layer.borderWidth = 0.4f; 150 | 151 | [btn setTitle :(NSString*)obj forState:UIControlStateNormal]; 152 | [btn setTitleColor:RGB(28, 28, 28) forState:UIControlStateNormal]; 153 | [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside]; 154 | 155 | [btnView addSubview:btn]; 156 | }]; 157 | 158 | return CGRectGetMaxY(btnView.frame); 159 | } 160 | 161 | -(void)show 162 | { 163 | [UIView animateWithDuration:0.3 animations:^{ 164 | self.bgView.alpha = 0.5; 165 | }]; 166 | 167 | [[UIApplication sharedApplication].keyWindow addSubview:self]; 168 | 169 | CAKeyframeAnimation *popAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; 170 | popAnimation.duration = 0.4; 171 | popAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 1.0f)], 172 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.0f)], 173 | [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 1.0f)], 174 | [NSValue valueWithCATransform3D:CATransform3DIdentity]]; 175 | popAnimation.keyTimes = @[@0.2f, @0.5f, @0.75f, @1.0f]; 176 | popAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 177 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], 178 | [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 179 | [[_contentView layer] addAnimation:popAnimation forKey:nil]; 180 | } 181 | 182 | -(void)dismiss 183 | { 184 | [UIView animateWithDuration:0.4 animations:^{ 185 | 186 | self.contentView.center = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame)+40); 187 | self.bgView.alpha = 0.0; 188 | self.contentView.alpha = 0.0; 189 | 190 | } completion:^(BOOL finished){ 191 | 192 | [self removeFromSuperview]; 193 | 194 | }]; 195 | 196 | } 197 | 198 | -(void)btnPressed:(UIButton*)btn 199 | { 200 | switch (btn.tag-221) { 201 | case 0: 202 | { 203 | if (self.btnArr.count==1) { 204 | if (_rightBlock) { 205 | _rightBlock(); 206 | } 207 | } 208 | 209 | if (_leftBlock) { 210 | _leftBlock(); 211 | } 212 | 213 | [self dismiss]; 214 | } 215 | break; 216 | case 1: 217 | { 218 | if (_rightBlock) { 219 | _rightBlock(); 220 | } 221 | [self dismiss]; 222 | } 223 | break; 224 | default: 225 | break; 226 | } 227 | } 228 | 229 | -(CGFloat)heightWithString:(NSString*)string fontSize:(CGFloat)fontSize width:(CGFloat)width 230 | { 231 | NSDictionary *attrs = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]}; 232 | return [string boundingRectWithSize:CGSizeMake(width, 0) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attrs context:nil].size.height; 233 | } 234 | 235 | -(void)dealloc 236 | { 237 | _leftBlock = nil; 238 | _rightBlock = nil; 239 | } 240 | @end 241 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BBAlertView.h" 11 | 12 | #define Titles [NSArray arrayWithObjects:@"单确认",@"左取消 右确认",@"左点击 右点击",nil] 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | [Titles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 24 | 25 | UIButton * btn = [UIButton buttonWithType:UIButtonTypeSystem]; 26 | btn.frame = CGRectMake(([[UIScreen mainScreen] bounds].size.width-250)/2, 120*(idx+1)+30*idx, 250, 30); 27 | btn.tag = 100+idx; 28 | [btn setTitle :(NSString*)obj forState:UIControlStateNormal]; 29 | [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside]; 30 | [self.view addSubview:btn]; 31 | 32 | }]; 33 | // Do any additional setup after loading the view, typically from a nib. 34 | } 35 | 36 | - (void)btnPressed:(UIButton*)btn 37 | { 38 | switch (btn.tag-100) { 39 | case 0: 40 | { 41 | [BBAlertView showAlertViewWithTitle:@"提示" message:@"您确认要这么做吗?" buttonTitles:@[@"确认"] confirmBlock:^{ 42 | NSLog(@"已确认"); 43 | }]; 44 | } 45 | break; 46 | case 1: 47 | { 48 | [BBAlertView showAlertViewWithTitle:@"提示" message:@"您确认要这么做吗?" buttonTitles:@[@"取消",@"确认"] confirmBlock:^{ 49 | NSLog(@"已确认"); 50 | }]; 51 | } 52 | break; 53 | case 2: 54 | { 55 | [BBAlertView showAlertViewWithTitle:@"提示" message:@"您确定要" buttonTitles:@[@"左点击",@"右点击"] leftBlock:^{ 56 | NSLog(@"左点击"); 57 | } rightBlock:^{ 58 | NSLog(@"右点击"); 59 | }]; 60 | } 61 | break; 62 | default: 63 | break; 64 | } 65 | } 66 | 67 | 68 | - (void)didReceiveMemoryWarning { 69 | [super didReceiveMemoryWarning]; 70 | // Dispose of any resources that can be recreated. 71 | } 72 | 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AlertViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. 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 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemoUITests/AlertViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AlertViewDemoUITests.m 3 | // AlertViewDemoUITests 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/17. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AlertViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation AlertViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /AlertViewDemo/AlertViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kazamihayato/iOS-CustomControl/0ba00e5d7e134ab09c1063163a92d217a7cbce72/MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/MBProgressHUD封装后直接调用.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MBProgressHUD封装后直接调用.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 3D7D23191D40EF3D0002D78D 16 | 17 | primary 18 | 19 | 20 | 3D7D23321D40EF3D0002D78D 21 | 22 | primary 23 | 24 | 25 | 3D7D233D1D40EF3D0002D78D 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kazamihayato/iOS-CustomControl/0ba00e5d7e134ab09c1063163a92d217a7cbce72/MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用.xcworkspace/xcuserdata/ZBB.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. 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 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. 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 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/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 | } -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/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 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/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 | 26 | 27 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/Class/MBHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBHUD.h 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/13. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MBHUD : UIView 12 | 13 | +(void)showLoadingInView:(UIView*)view; 14 | 15 | +(void)showLoadingInView:(UIView*)view title:(NSString*)title; 16 | 17 | +(void)showLoadingInView:(UIView*)view title:(NSString*)title delay:(NSTimeInterval)delay; 18 | 19 | +(void)showHUDWithTitle:(NSString*)title InView:(UIView*)view; 20 | 21 | +(void)hideHUDInView:(UIView*)view; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/Class/MBHUD.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBHUD.m 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/13. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "MBHUD.h" 10 | #import "MBProgressHUD.h" 11 | 12 | 13 | static const NSInteger MBHUDView_tag=1980; 14 | 15 | @implementation MBHUD 16 | 17 | +(void)showLoadingInView:(UIView *)view 18 | { 19 | [self showLoadingInView:view title:nil delay:0]; 20 | } 21 | 22 | +(void)showLoadingInView:(UIView *)view title:(NSString *)title 23 | { 24 | [self showLoadingInView:view title:title delay:0]; 25 | } 26 | 27 | +(void)showLoadingInView:(UIView*)view title:(NSString*)title delay:(NSTimeInterval)delay 28 | { 29 | UIView *showInView = nil; 30 | if (view) { 31 | showInView = view; 32 | }else { 33 | showInView = [UIApplication sharedApplication].keyWindow; 34 | } 35 | [self hideHUDInView:view]; 36 | 37 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:showInView animated:YES]; 38 | hud.mode = MBProgressHUDModeIndeterminate; 39 | hud.labelText = !title?@"加载中":title; 40 | hud.labelColor = [UIColor whiteColor]; 41 | hud.labelFont = [UIFont systemFontOfSize:14]; 42 | hud.tag = MBHUDView_tag; 43 | if (delay>0) { 44 | [hud hide:YES afterDelay:delay]; 45 | } 46 | } 47 | 48 | +(void)showHUDWithTitle:(NSString*)title InView:(UIView*)view 49 | { 50 | [self showHUDWithTitle:title InView:view delay:1.5]; 51 | } 52 | 53 | +(void)showHUDWithTitle:(NSString*)title InView:(UIView*)view delay:(NSTimeInterval)delay 54 | { 55 | UIView *showInView = nil; 56 | if (view) { 57 | showInView = view; 58 | }else { 59 | showInView = [UIApplication sharedApplication].keyWindow; 60 | } 61 | [self hideHUDInView:view]; 62 | 63 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:showInView animated:YES]; 64 | hud.mode = MBProgressHUDModeText; 65 | hud.margin = 10; 66 | hud.labelText = title; 67 | hud.labelColor = [UIColor whiteColor]; 68 | hud.labelFont = [UIFont systemFontOfSize:14]; 69 | hud.removeFromSuperViewOnHide = YES; 70 | hud.tag = MBHUDView_tag; 71 | [hud hide:YES afterDelay:delay]; 72 | } 73 | 74 | +(void)hideHUDInView:(UIView*)view 75 | { 76 | UIView *showInView = nil; 77 | if (view) { 78 | showInView = view; 79 | }else { 80 | showInView = [UIApplication sharedApplication].keyWindow; 81 | } 82 | MBProgressHUD *hud = [view viewWithTag:MBHUDView_tag]; 83 | if(hud) 84 | { 85 | [hud hide:YES]; 86 | } 87 | } 88 | 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/Class/NSObject+MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MBProgressHUD.h 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (MBProgressHUD) 12 | 13 | - (void)hide; 14 | 15 | - (void)showHUDWindowWithTitle:(NSString*)title; 16 | @end 17 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/Class/NSObject+MBProgressHUD.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+MBProgressHUD.m 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "NSObject+MBProgressHUD.h" 10 | #import "MBHUD.h" 11 | @implementation NSObject (MBProgressHUD) 12 | 13 | - (void)hide 14 | { 15 | [MBHUD hideHUDInView:nil]; 16 | } 17 | 18 | - (void)showHUDWindowWithTitle:(NSString*)title 19 | { 20 | [MBHUD showHUDWithTitle:title InView:nil]; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/Class/UIViewController+MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MBProgressHUD.h 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIViewController (MBProgressHUD) 12 | 13 | - (void)showLoading; 14 | 15 | - (void)showLoadingWithTitle:(NSString*)title; 16 | 17 | - (void)showLoadingWithTitle:(NSString *)title delay:(NSTimeInterval)delay; 18 | 19 | - (void)hide; 20 | 21 | - (void)showHUDWithTitle:(NSString*)title; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/Class/UIViewController+MBProgressHUD.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MBProgressHUD.m 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+MBProgressHUD.h" 10 | #import "MBHUD.h" 11 | 12 | @implementation UIViewController (MBProgressHUD) 13 | - (void)showLoading 14 | { 15 | [MBHUD showLoadingInView:self.view]; 16 | } 17 | 18 | - (void)showLoadingWithTitle:(NSString*)title 19 | { 20 | [MBHUD showLoadingInView:self.view title:title]; 21 | } 22 | 23 | - (void)showLoadingWithTitle:(NSString *)title delay:(NSTimeInterval)delay 24 | { 25 | [MBHUD showLoadingInView:self.view title:title delay:delay]; 26 | } 27 | 28 | - (void)hide 29 | { 30 | [MBHUD hideHUDInView:self.view]; 31 | } 32 | 33 | - (void)showHUDWithTitle:(NSString*)title 34 | { 35 | [MBHUD showHUDWithTitle:title InView:self.view]; 36 | } 37 | @end 38 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/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 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MBProgressHUD类别分装 4 | // 5 | // Created by 庄BB的MacBook on 16/7/25. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MBProgressHUD类别分装 4 | // 5 | // Created by 庄BB的MacBook on 16/7/25. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIViewController+MBProgressHUD.h" 11 | #import "MBHUD.h" 12 | 13 | #define Titles [NSArray arrayWithObjects:@"加载中",@"加载后显示文字",@"显示文字",nil] 14 | #define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width 15 | #define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height 16 | 17 | @interface ViewController () 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | [Titles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 27 | 28 | UIButton * btn = [UIButton buttonWithType:UIButtonTypeSystem]; 29 | btn.frame = CGRectMake((SCREEN_WIDTH-250)/2, 120*(idx+1)+30*idx, 250, 30); 30 | btn.tag = 100+idx; 31 | [btn setTitle :(NSString*)obj forState:UIControlStateNormal]; 32 | [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside]; 33 | [self.view addSubview:btn]; 34 | 35 | }]; 36 | } 37 | 38 | -(void)btnPressed:(UIButton*)btn 39 | { 40 | switch (btn.tag-100) { 41 | //加在视图控制View上,用户扔可以点击返回 42 | case 0: 43 | { 44 | [self showLoadingWithTitle:@"加载中" delay:5.0]; 45 | } 46 | break; 47 | case 1: 48 | { 49 | [self showLoading]; 50 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 51 | [self showHUDWithTitle:@"加载成功"]; 52 | }); 53 | } 54 | break; 55 | case 2: 56 | { 57 | [self showHUDWithTitle:@"加载成功"]; 58 | } 59 | break; 60 | default: 61 | break; 62 | } 63 | } 64 | 65 | -(void)loadData 66 | { 67 | 68 | } 69 | 70 | 71 | - (void)didReceiveMemoryWarning { 72 | [super didReceiveMemoryWarning]; 73 | // Dispose of any resources that can be recreated. 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MBProgressHUD封装后直接调用 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. 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 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用Tests/MBProgressHUD_______Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD_______Tests.m 3 | // MBProgressHUD封装后直接调用Tests 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MBProgressHUD_______Tests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation MBProgressHUD_______Tests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/MBProgressHUD封装后直接调用UITests/MBProgressHUD_______UITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD_______UITests.m 3 | // MBProgressHUD封装后直接调用UITests 4 | // 5 | // Created by 庄BB的MacBook on 16/7/21. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MBProgressHUD_______UITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation MBProgressHUD_______UITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/PodFile: -------------------------------------------------------------------------------- 1 | platform:ios,"7.0" 2 | target "MBProgressHUD封装后直接调用" do pod "MBProgressHUD","~>0.9.2"end 3 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MBProgressHUD (0.9.2) 3 | 4 | DEPENDENCIES: 5 | - MBProgressHUD (~> 0.9.2) 6 | 7 | SPEC CHECKSUMS: 8 | MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1 9 | 10 | PODFILE CHECKSUM: 2ac248b914a0550e6b2e6cde9f0524fcca412d73 11 | 12 | COCOAPODS: 1.0.1 13 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Headers/Private/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | ../../../MBProgressHUD/MBProgressHUD.h -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Headers/Public/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | ../../../MBProgressHUD/MBProgressHUD.h -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/MBProgressHUD/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2015 Matej Bukovinski 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. -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/MBProgressHUD/MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD.h 3 | // Version 0.9.2 4 | // Created by Matej Bukovinski on 2.4.09. 5 | // 6 | 7 | // This code is distributed under the terms and conditions of the MIT license. 8 | 9 | // Copyright (c) 2009-2015 Matej Bukovinski 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | #import 30 | #import 31 | #import 32 | 33 | @protocol MBProgressHUDDelegate; 34 | 35 | 36 | typedef NS_ENUM(NSInteger, MBProgressHUDMode) { 37 | /** Progress is shown using an UIActivityIndicatorView. This is the default. */ 38 | MBProgressHUDModeIndeterminate, 39 | /** Progress is shown using a round, pie-chart like, progress view. */ 40 | MBProgressHUDModeDeterminate, 41 | /** Progress is shown using a horizontal progress bar */ 42 | MBProgressHUDModeDeterminateHorizontalBar, 43 | /** Progress is shown using a ring-shaped progress view. */ 44 | MBProgressHUDModeAnnularDeterminate, 45 | /** Shows a custom view */ 46 | MBProgressHUDModeCustomView, 47 | /** Shows only labels */ 48 | MBProgressHUDModeText 49 | }; 50 | 51 | typedef NS_ENUM(NSInteger, MBProgressHUDAnimation) { 52 | /** Opacity animation */ 53 | MBProgressHUDAnimationFade, 54 | /** Opacity + scale animation */ 55 | MBProgressHUDAnimationZoom, 56 | MBProgressHUDAnimationZoomOut = MBProgressHUDAnimationZoom, 57 | MBProgressHUDAnimationZoomIn 58 | }; 59 | 60 | 61 | #ifndef MB_INSTANCETYPE 62 | #if __has_feature(objc_instancetype) 63 | #define MB_INSTANCETYPE instancetype 64 | #else 65 | #define MB_INSTANCETYPE id 66 | #endif 67 | #endif 68 | 69 | #ifndef MB_STRONG 70 | #if __has_feature(objc_arc) 71 | #define MB_STRONG strong 72 | #else 73 | #define MB_STRONG retain 74 | #endif 75 | #endif 76 | 77 | #ifndef MB_WEAK 78 | #if __has_feature(objc_arc_weak) 79 | #define MB_WEAK weak 80 | #elif __has_feature(objc_arc) 81 | #define MB_WEAK unsafe_unretained 82 | #else 83 | #define MB_WEAK assign 84 | #endif 85 | #endif 86 | 87 | #if NS_BLOCKS_AVAILABLE 88 | typedef void (^MBProgressHUDCompletionBlock)(); 89 | #endif 90 | 91 | 92 | /** 93 | * Displays a simple HUD window containing a progress indicator and two optional labels for short messages. 94 | * 95 | * This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class. 96 | * The MBProgressHUD window spans over the entire space given to it by the initWithFrame constructor and catches all 97 | * user input on this region, thereby preventing the user operations on components below the view. The HUD itself is 98 | * drawn centered as a rounded semi-transparent view which resizes depending on the user specified content. 99 | * 100 | * This view supports four modes of operation: 101 | * - MBProgressHUDModeIndeterminate - shows a UIActivityIndicatorView 102 | * - MBProgressHUDModeDeterminate - shows a custom round progress indicator 103 | * - MBProgressHUDModeAnnularDeterminate - shows a custom annular progress indicator 104 | * - MBProgressHUDModeCustomView - shows an arbitrary, user specified view (see `customView`) 105 | * 106 | * All three modes can have optional labels assigned: 107 | * - If the labelText property is set and non-empty then a label containing the provided content is placed below the 108 | * indicator view. 109 | * - If also the detailsLabelText property is set then another label is placed below the first label. 110 | */ 111 | @interface MBProgressHUD : UIView 112 | 113 | /** 114 | * Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:. 115 | * 116 | * @note This method sets `removeFromSuperViewOnHide`. The HUD will automatically be removed from the view hierarchy when hidden. 117 | * 118 | * @param view The view that the HUD will be added to 119 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 120 | * animations while appearing. 121 | * @return A reference to the created HUD. 122 | * 123 | * @see hideHUDForView:animated: 124 | * @see animationType 125 | */ 126 | + (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated; 127 | 128 | /** 129 | * Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:. 130 | * 131 | * @note This method sets `removeFromSuperViewOnHide`. The HUD will automatically be removed from the view hierarchy when hidden. 132 | * 133 | * @param view The view that is going to be searched for a HUD subview. 134 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 135 | * animations while disappearing. 136 | * @return YES if a HUD was found and removed, NO otherwise. 137 | * 138 | * @see showHUDAddedTo:animated: 139 | * @see animationType 140 | */ 141 | + (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated; 142 | 143 | /** 144 | * Finds all the HUD subviews and hides them. 145 | * 146 | * @note This method sets `removeFromSuperViewOnHide`. The HUDs will automatically be removed from the view hierarchy when hidden. 147 | * 148 | * @param view The view that is going to be searched for HUD subviews. 149 | * @param animated If set to YES the HUDs will disappear using the current animationType. If set to NO the HUDs will not use 150 | * animations while disappearing. 151 | * @return the number of HUDs found and removed. 152 | * 153 | * @see hideHUDForView:animated: 154 | * @see animationType 155 | */ 156 | + (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated; 157 | 158 | /** 159 | * Finds the top-most HUD subview and returns it. 160 | * 161 | * @param view The view that is going to be searched. 162 | * @return A reference to the last HUD subview discovered. 163 | */ 164 | + (MB_INSTANCETYPE)HUDForView:(UIView *)view; 165 | 166 | /** 167 | * Finds all HUD subviews and returns them. 168 | * 169 | * @param view The view that is going to be searched. 170 | * @return All found HUD views (array of MBProgressHUD objects). 171 | */ 172 | + (NSArray *)allHUDsForView:(UIView *)view; 173 | 174 | /** 175 | * A convenience constructor that initializes the HUD with the window's bounds. Calls the designated constructor with 176 | * window.bounds as the parameter. 177 | * 178 | * @param window The window instance that will provide the bounds for the HUD. Should be the same instance as 179 | * the HUD's superview (i.e., the window that the HUD will be added to). 180 | */ 181 | - (id)initWithWindow:(UIWindow *)window; 182 | 183 | /** 184 | * A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with 185 | * view.bounds as the parameter 186 | * 187 | * @param view The view instance that will provide the bounds for the HUD. Should be the same instance as 188 | * the HUD's superview (i.e., the view that the HUD will be added to). 189 | */ 190 | - (id)initWithView:(UIView *)view; 191 | 192 | /** 193 | * Display the HUD. You need to make sure that the main thread completes its run loop soon after this method call so 194 | * the user interface can be updated. Call this method when your task is already set-up to be executed in a new thread 195 | * (e.g., when using something like NSOperation or calling an asynchronous call like NSURLRequest). 196 | * 197 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 198 | * animations while appearing. 199 | * 200 | * @see animationType 201 | */ 202 | - (void)show:(BOOL)animated; 203 | 204 | /** 205 | * Hide the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 206 | * hide the HUD when your task completes. 207 | * 208 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 209 | * animations while disappearing. 210 | * 211 | * @see animationType 212 | */ 213 | - (void)hide:(BOOL)animated; 214 | 215 | /** 216 | * Hide the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 217 | * hide the HUD when your task completes. 218 | * 219 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 220 | * animations while disappearing. 221 | * @param delay Delay in seconds until the HUD is hidden. 222 | * 223 | * @see animationType 224 | */ 225 | - (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay; 226 | 227 | /** 228 | * Shows the HUD while a background task is executing in a new thread, then hides the HUD. 229 | * 230 | * This method also takes care of autorelease pools so your method does not have to be concerned with setting up a 231 | * pool. 232 | * 233 | * @param method The method to be executed while the HUD is shown. This method will be executed in a new thread. 234 | * @param target The object that the target method belongs to. 235 | * @param object An optional object to be passed to the method. 236 | * @param animated If set to YES the HUD will (dis)appear using the current animationType. If set to NO the HUD will not use 237 | * animations while (dis)appearing. 238 | */ 239 | - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated; 240 | 241 | #if NS_BLOCKS_AVAILABLE 242 | 243 | /** 244 | * Shows the HUD while a block is executing on a background queue, then hides the HUD. 245 | * 246 | * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: 247 | */ 248 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block; 249 | 250 | /** 251 | * Shows the HUD while a block is executing on a background queue, then hides the HUD. 252 | * 253 | * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: 254 | */ 255 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(MBProgressHUDCompletionBlock)completion; 256 | 257 | /** 258 | * Shows the HUD while a block is executing on the specified dispatch queue, then hides the HUD. 259 | * 260 | * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: 261 | */ 262 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue; 263 | 264 | /** 265 | * Shows the HUD while a block is executing on the specified dispatch queue, executes completion block on the main queue, and then hides the HUD. 266 | * 267 | * @param animated If set to YES the HUD will (dis)appear using the current animationType. If set to NO the HUD will 268 | * not use animations while (dis)appearing. 269 | * @param block The block to be executed while the HUD is shown. 270 | * @param queue The dispatch queue on which the block should be executed. 271 | * @param completion The block to be executed on completion. 272 | * 273 | * @see completionBlock 274 | */ 275 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue 276 | completionBlock:(MBProgressHUDCompletionBlock)completion; 277 | 278 | /** 279 | * A block that gets called after the HUD was completely hidden. 280 | */ 281 | @property (copy) MBProgressHUDCompletionBlock completionBlock; 282 | 283 | #endif 284 | 285 | /** 286 | * MBProgressHUD operation mode. The default is MBProgressHUDModeIndeterminate. 287 | * 288 | * @see MBProgressHUDMode 289 | */ 290 | @property (assign) MBProgressHUDMode mode; 291 | 292 | /** 293 | * The animation type that should be used when the HUD is shown and hidden. 294 | * 295 | * @see MBProgressHUDAnimation 296 | */ 297 | @property (assign) MBProgressHUDAnimation animationType; 298 | 299 | /** 300 | * The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView. 301 | * For best results use a 37 by 37 pixel view (so the bounds match the built in indicator bounds). 302 | */ 303 | @property (MB_STRONG) UIView *customView; 304 | 305 | /** 306 | * The HUD delegate object. 307 | * 308 | * @see MBProgressHUDDelegate 309 | */ 310 | @property (MB_WEAK) id delegate; 311 | 312 | /** 313 | * An optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit 314 | * the entire text. If the text is too long it will get clipped by displaying "..." at the end. If left unchanged or 315 | * set to @"", then no message is displayed. 316 | */ 317 | @property (copy) NSString *labelText; 318 | 319 | /** 320 | * An optional details message displayed below the labelText message. This message is displayed only if the labelText 321 | * property is also set and is different from an empty string (@""). The details text can span multiple lines. 322 | */ 323 | @property (copy) NSString *detailsLabelText; 324 | 325 | /** 326 | * The opacity of the HUD window. Defaults to 0.8 (80% opacity). 327 | */ 328 | @property (assign) float opacity; 329 | 330 | /** 331 | * The color of the HUD window. Defaults to black. If this property is set, color is set using 332 | * this UIColor and the opacity property is not used. using retain because performing copy on 333 | * UIColor base colors (like [UIColor greenColor]) cause problems with the copyZone. 334 | */ 335 | @property (MB_STRONG) UIColor *color; 336 | 337 | /** 338 | * The x-axis offset of the HUD relative to the centre of the superview. 339 | */ 340 | @property (assign) float xOffset; 341 | 342 | /** 343 | * The y-axis offset of the HUD relative to the centre of the superview. 344 | */ 345 | @property (assign) float yOffset; 346 | 347 | /** 348 | * The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views). 349 | * Defaults to 20.0 350 | */ 351 | @property (assign) float margin; 352 | 353 | /** 354 | * The corner radius for the HUD 355 | * Defaults to 10.0 356 | */ 357 | @property (assign) float cornerRadius; 358 | 359 | /** 360 | * Cover the HUD background view with a radial gradient. 361 | */ 362 | @property (assign) BOOL dimBackground; 363 | 364 | /* 365 | * Grace period is the time (in seconds) that the invoked method may be run without 366 | * showing the HUD. If the task finishes before the grace time runs out, the HUD will 367 | * not be shown at all. 368 | * This may be used to prevent HUD display for very short tasks. 369 | * Defaults to 0 (no grace time). 370 | * Grace time functionality is only supported when the task status is known! 371 | * @see taskInProgress 372 | */ 373 | @property (assign) float graceTime; 374 | 375 | /** 376 | * The minimum time (in seconds) that the HUD is shown. 377 | * This avoids the problem of the HUD being shown and than instantly hidden. 378 | * Defaults to 0 (no minimum show time). 379 | */ 380 | @property (assign) float minShowTime; 381 | 382 | /** 383 | * Indicates that the executed operation is in progress. Needed for correct graceTime operation. 384 | * If you don't set a graceTime (different than 0.0) this does nothing. 385 | * This property is automatically set when using showWhileExecuting:onTarget:withObject:animated:. 386 | * When threading is done outside of the HUD (i.e., when the show: and hide: methods are used directly), 387 | * you need to set this property when your task starts and completes in order to have normal graceTime 388 | * functionality. 389 | */ 390 | @property (assign) BOOL taskInProgress; 391 | 392 | /** 393 | * Removes the HUD from its parent view when hidden. 394 | * Defaults to NO. 395 | */ 396 | @property (assign) BOOL removeFromSuperViewOnHide; 397 | 398 | /** 399 | * Font to be used for the main label. Set this property if the default is not adequate. 400 | */ 401 | @property (MB_STRONG) UIFont* labelFont; 402 | 403 | /** 404 | * Color to be used for the main label. Set this property if the default is not adequate. 405 | */ 406 | @property (MB_STRONG) UIColor* labelColor; 407 | 408 | /** 409 | * Font to be used for the details label. Set this property if the default is not adequate. 410 | */ 411 | @property (MB_STRONG) UIFont* detailsLabelFont; 412 | 413 | /** 414 | * Color to be used for the details label. Set this property if the default is not adequate. 415 | */ 416 | @property (MB_STRONG) UIColor* detailsLabelColor; 417 | 418 | /** 419 | * The color of the activity indicator. Defaults to [UIColor whiteColor] 420 | * Does nothing on pre iOS 5. 421 | */ 422 | @property (MB_STRONG) UIColor *activityIndicatorColor; 423 | 424 | /** 425 | * The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. 426 | */ 427 | @property (assign) float progress; 428 | 429 | /** 430 | * The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size). 431 | */ 432 | @property (assign) CGSize minSize; 433 | 434 | 435 | /** 436 | * The actual size of the HUD bezel. 437 | * You can use this to limit touch handling on the bezel area only. 438 | * @see https://github.com/jdg/MBProgressHUD/pull/200 439 | */ 440 | @property (atomic, assign, readonly) CGSize size; 441 | 442 | 443 | /** 444 | * Force the HUD dimensions to be equal if possible. 445 | */ 446 | @property (assign, getter = isSquare) BOOL square; 447 | 448 | @end 449 | 450 | 451 | @protocol MBProgressHUDDelegate 452 | 453 | @optional 454 | 455 | /** 456 | * Called after the HUD was fully hidden from the screen. 457 | */ 458 | - (void)hudWasHidden:(MBProgressHUD *)hud; 459 | 460 | @end 461 | 462 | 463 | /** 464 | * A progress view for showing definite progress by filling up a circle (pie chart). 465 | */ 466 | @interface MBRoundProgressView : UIView 467 | 468 | /** 469 | * Progress (0.0 to 1.0) 470 | */ 471 | @property (nonatomic, assign) float progress; 472 | 473 | /** 474 | * Indicator progress color. 475 | * Defaults to white [UIColor whiteColor] 476 | */ 477 | @property (nonatomic, MB_STRONG) UIColor *progressTintColor; 478 | 479 | /** 480 | * Indicator background (non-progress) color. 481 | * Defaults to translucent white (alpha 0.1) 482 | */ 483 | @property (nonatomic, MB_STRONG) UIColor *backgroundTintColor; 484 | 485 | /* 486 | * Display mode - NO = round or YES = annular. Defaults to round. 487 | */ 488 | @property (nonatomic, assign, getter = isAnnular) BOOL annular; 489 | 490 | @end 491 | 492 | 493 | /** 494 | * A flat bar progress view. 495 | */ 496 | @interface MBBarProgressView : UIView 497 | 498 | /** 499 | * Progress (0.0 to 1.0) 500 | */ 501 | @property (nonatomic, assign) float progress; 502 | 503 | /** 504 | * Bar border line color. 505 | * Defaults to white [UIColor whiteColor]. 506 | */ 507 | @property (nonatomic, MB_STRONG) UIColor *lineColor; 508 | 509 | /** 510 | * Bar background color. 511 | * Defaults to clear [UIColor clearColor]; 512 | */ 513 | @property (nonatomic, MB_STRONG) UIColor *progressRemainingColor; 514 | 515 | /** 516 | * Bar progress color. 517 | * Defaults to white [UIColor whiteColor]. 518 | */ 519 | @property (nonatomic, MB_STRONG) UIColor *progressColor; 520 | 521 | @end 522 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/MBProgressHUD/README.mdown: -------------------------------------------------------------------------------- 1 | # MBProgressHUD [![Build Status](https://travis-ci.org/matej/MBProgressHUD.svg?branch=master)](https://travis-ci.org/matej/MBProgressHUD) 2 | 3 | MBProgressHUD is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features. 4 | 5 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/1-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/1.png) 6 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/2-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/2.png) 7 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/3-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/3.png) 8 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/4-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/4.png) 9 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/5-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/5.png) 10 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/6-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/6.png) 11 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/7-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/7.png) 12 | 13 | ## Requirements 14 | 15 | MBProgressHUD works on any iOS version and is compatible with both ARC and non-ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates: 16 | 17 | * Foundation.framework 18 | * UIKit.framework 19 | * CoreGraphics.framework 20 | 21 | You will need the latest developer tools in order to build MBProgressHUD. Old Xcode versions might work, but compatibility will not be explicitly maintained. 22 | 23 | ## Adding MBProgressHUD to your project 24 | 25 | ### Cocoapods 26 | 27 | [CocoaPods](http://cocoapods.org) is the recommended way to add MBProgressHUD to your project. 28 | 29 | 1. Add a pod entry for MBProgressHUD to your Podfile `pod 'MBProgressHUD', '~> 0.9.2'` 30 | 2. Install the pod(s) by running `pod install`. 31 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 32 | 33 | ### Source files 34 | 35 | Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` source files to your project. 36 | 37 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/archive/master.zip) or add the repository as a git submodule to your git-tracked project. 38 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. 39 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 40 | 41 | ### Static library 42 | 43 | You can also add MBProgressHUD as a static library to your project or workspace. 44 | 45 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/downloads) or add the repository as a git submodule to your git-tracked project. 46 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view"). 47 | 3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add `libMBProgressHUD.a`. You might also need to add `MBProgressHUD` to the Target Dependencies list. 48 | 4. Include MBProgressHUD wherever you need it with `#import `. 49 | 50 | ## Usage 51 | 52 | The main guideline you need to follow when dealing with MBProgressHUD while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using MBProgressHUD is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread. 53 | 54 | ```objective-c 55 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 56 | dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 57 | // Do something... 58 | dispatch_async(dispatch_get_main_queue(), ^{ 59 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 60 | }); 61 | }); 62 | ``` 63 | 64 | If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns. 65 | 66 | ```objective-c 67 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 68 | hud.mode = MBProgressHUDModeAnnularDeterminate; 69 | hud.labelText = @"Loading"; 70 | [self doSomethingInBackgroundWithProgressCallback:^(float progress) { 71 | hud.progress = progress; 72 | } completionCallback:^{ 73 | [hud hide:YES]; 74 | }]; 75 | ``` 76 | 77 | UI updates should always be done on the main thread. Some MBProgressHUD setters are however considered "thread safe" and can be called from background threads. Those also include `setMode:`, `setCustomView:`, `setLabelText:`, `setLabelFont:`, `setDetailsLabelText:`, `setDetailsLabelFont:` and `setProgress:`. 78 | 79 | If you need to run your long-running task in the main thread, you should perform it with a slight delay, so UIKit will have enough time to update the UI (i.e., draw the HUD) before you block the main thread with your task. 80 | 81 | ```objective-c 82 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 83 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC); 84 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 85 | // Do something... 86 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 87 | }); 88 | ``` 89 | 90 | You should be aware that any HUD updates issued inside the above block won't be displayed until the block completes. 91 | 92 | For more examples, including how to use MBProgressHUD with asynchronous operations such as NSURLConnection, take a look at the bundled demo project. Extensive API documentation is provided in the header file (MBProgressHUD.h). 93 | 94 | 95 | ## License 96 | 97 | This code is distributed under the terms and conditions of the [MIT license](LICENSE). 98 | 99 | ## Change-log 100 | 101 | A brief summary of each MBProgressHUD release can be found on the [wiki](https://github.com/matej/MBProgressHUD/wiki/Change-log). 102 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MBProgressHUD (0.9.2) 3 | 4 | DEPENDENCIES: 5 | - MBProgressHUD (~> 0.9.2) 6 | 7 | SPEC CHECKSUMS: 8 | MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1 9 | 10 | PODFILE CHECKSUM: 2ac248b914a0550e6b2e6cde9f0524fcca412d73 11 | 12 | COCOAPODS: 1.0.1 13 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Pods.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/MBProgressHUD.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Pods.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/Pods-MBProgressHUD封装后直接调用.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Pods.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MBProgressHUD.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-MBProgressHUD封装后直接调用.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | FCE9C67CAB78720FF280B35FCF9BDD9D 21 | 22 | primary 23 | 24 | 25 | FE2F1D7B9D9FCEA148517E4657B243F4 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/MBProgressHUD/MBProgressHUD-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MBProgressHUD : NSObject 3 | @end 4 | @implementation PodsDummy_MBProgressHUD 5 | @end 6 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/MBProgressHUD/MBProgressHUD-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/MBProgressHUD/MBProgressHUD.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MBProgressHUD" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" 4 | OTHER_LDFLAGS = -framework "CoreGraphics" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MBProgressHUD 5 | 6 | Copyright (c) 2009-2015 Matej Bukovinski 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 | Generated by CocoaPods - https://cocoapods.org 26 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用-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) 2009-2015 Matej Bukovinski 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 | Title 37 | MBProgressHUD 38 | Type 39 | PSGroupSpecifier 40 | 41 | 42 | FooterText 43 | Generated by CocoaPods - https://cocoapods.org 44 | Title 45 | 46 | Type 47 | PSGroupSpecifier 48 | 49 | 50 | StringsTable 51 | Acknowledgements 52 | Title 53 | Acknowledgements 54 | 55 | 56 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_MBProgressHUD_______ : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_MBProgressHUD_______ 5 | @end 6 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用-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 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用-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} ${TARGET_DEVICE_ARGS}" 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}" ${TARGET_DEVICE_ARGS} 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 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MBProgressHUD" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"MBProgressHUD" -framework "CoreGraphics" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /MBProgressHUD封装后直接调用/Pods/Target Support Files/Pods-MBProgressHUD封装后直接调用/Pods-MBProgressHUD封装后直接调用.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/MBProgressHUD" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/MBProgressHUD" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"MBProgressHUD" -framework "CoreGraphics" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kazamihayato/iOS-CustomControl/0ba00e5d7e134ab09c1063163a92d217a7cbce72/PageViewControllerDemo/PageViewControllerDemo.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/PageViewControllerDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PageViewControllerDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 3D7F5A281D4B0D5700D06252 16 | 17 | primary 18 | 19 | 20 | 3D7F5A411D4B0D5700D06252 21 | 22 | primary 23 | 24 | 25 | 3D7F5A4C1D4B0D5700D06252 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. 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 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "CommonPageViewController.h" 11 | 12 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 13 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 14 | 15 | @interface AppDelegate () 16 | 17 | @end 18 | 19 | @implementation AppDelegate 20 | 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | 24 | self.window.rootViewController=[[CommonPageViewController alloc] initWithPageViewFrame:CGRectMake(0, 64,SCREEN_WIDTH, SCREEN_HEIGHT)]; 25 | 26 | [self.window makeKeyAndVisible]; 27 | 28 | 29 | // Override point for customization after application launch. 30 | return YES; 31 | } 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // 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. 35 | // 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. 36 | } 37 | 38 | - (void)applicationDidEnterBackground:(UIApplication *)application { 39 | // 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. 40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | - (void)applicationDidBecomeActive:(UIApplication *)application { 48 | // 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. 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/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 | } -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/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 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/Base/HMSegmentedControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // HMSegmentedControl.h 3 | // HMSegmentedControl 4 | // 5 | // Created by Hesham Abd-Elmegid on 23/12/12. 6 | // Copyright (c) 2012-2015 Hesham Abd-Elmegid. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class HMSegmentedControl; 12 | 13 | typedef void (^IndexChangeBlock)(NSInteger index); 14 | typedef NSAttributedString *(^HMTitleFormatterBlock)(HMSegmentedControl *segmentedControl, NSString *title, NSUInteger index, BOOL selected); 15 | 16 | typedef enum { 17 | HMSegmentedControlSelectionStyleTextWidthStripe, // Indicator width will only be as big as the text width 18 | HMSegmentedControlSelectionStyleFullWidthStripe, // Indicator width will fill the whole segment 19 | HMSegmentedControlSelectionStyleBox, // A rectangle that covers the whole segment 20 | HMSegmentedControlSelectionStyleArrow // An arrow in the middle of the segment pointing up or down depending on `HMSegmentedControlSelectionIndicatorLocation` 21 | } HMSegmentedControlSelectionStyle; 22 | 23 | typedef enum { 24 | HMSegmentedControlSelectionIndicatorLocationUp, 25 | HMSegmentedControlSelectionIndicatorLocationDown, 26 | HMSegmentedControlSelectionIndicatorLocationNone // No selection indicator 27 | } HMSegmentedControlSelectionIndicatorLocation; 28 | 29 | typedef enum { 30 | HMSegmentedControlSegmentWidthStyleFixed, // Segment width is fixed 31 | HMSegmentedControlSegmentWidthStyleDynamic, // Segment width will only be as big as the text width (including inset) 32 | } HMSegmentedControlSegmentWidthStyle; 33 | 34 | typedef NS_OPTIONS(NSInteger, HMSegmentedControlBorderType) { 35 | HMSegmentedControlBorderTypeNone = 0, 36 | HMSegmentedControlBorderTypeTop = (1 << 0), 37 | HMSegmentedControlBorderTypeLeft = (1 << 1), 38 | HMSegmentedControlBorderTypeBottom = (1 << 2), 39 | HMSegmentedControlBorderTypeRight = (1 << 3) 40 | }; 41 | 42 | enum { 43 | HMSegmentedControlNoSegment = -1 // Segment index for no selected segment 44 | }; 45 | 46 | typedef enum { 47 | HMSegmentedControlTypeText, 48 | HMSegmentedControlTypeImages, 49 | HMSegmentedControlTypeTextImages 50 | } HMSegmentedControlType; 51 | 52 | @interface HMSegmentedControl : UIControl 53 | 54 | @property (nonatomic, strong) NSArray *sectionTitles; 55 | @property (nonatomic, strong) NSArray *sectionImages; 56 | @property (nonatomic, strong) NSArray *sectionSelectedImages; 57 | 58 | /** 59 | Provide a block to be executed when selected index is changed. 60 | 61 | Alternativly, you could use `addTarget:action:forControlEvents:` 62 | */ 63 | @property (nonatomic, copy) IndexChangeBlock indexChangeBlock; 64 | 65 | /** 66 | Used to apply custom text styling to titles when set. 67 | 68 | When this block is set, no additional styling is applied to the `NSAttributedString` object returned from this block. 69 | */ 70 | @property (nonatomic, copy) HMTitleFormatterBlock titleFormatter; 71 | 72 | /** 73 | Text attributes to apply to item title text. 74 | */ 75 | @property (nonatomic, strong) NSDictionary *titleTextAttributes UI_APPEARANCE_SELECTOR; 76 | 77 | /* 78 | Text attributes to apply to selected item title text. 79 | 80 | Attributes not set in this dictionary are inherited from `titleTextAttributes`. 81 | */ 82 | @property (nonatomic, strong) NSDictionary *selectedTitleTextAttributes UI_APPEARANCE_SELECTOR; 83 | 84 | /** 85 | Segmented control background color. 86 | 87 | Default is `[UIColor whiteColor]` 88 | */ 89 | @property (nonatomic, strong) UIColor *backgroundColor UI_APPEARANCE_SELECTOR; 90 | 91 | /** 92 | Color for the selection indicator stripe/box 93 | 94 | Default is `R:52, G:181, B:229` 95 | */ 96 | @property (nonatomic, strong) UIColor *selectionIndicatorColor UI_APPEARANCE_SELECTOR; 97 | 98 | /** 99 | Color for the vertical divider between segments. 100 | 101 | Default is `[UIColor blackColor]` 102 | */ 103 | @property (nonatomic, strong) UIColor *verticalDividerColor UI_APPEARANCE_SELECTOR; 104 | 105 | /** 106 | Opacity for the seletion indicator box. 107 | 108 | Default is `0.2f` 109 | */ 110 | @property (nonatomic) CGFloat selectionIndicatorBoxOpacity; 111 | 112 | /** 113 | Width the vertical divider between segments that is added when `verticalDividerEnabled` is set to YES. 114 | 115 | Default is `1.0f` 116 | */ 117 | @property (nonatomic, assign) CGFloat verticalDividerWidth; 118 | 119 | /** 120 | Specifies the style of the control 121 | 122 | Default is `HMSegmentedControlTypeText` 123 | */ 124 | @property (nonatomic, assign) HMSegmentedControlType type; 125 | 126 | /** 127 | Specifies the style of the selection indicator. 128 | 129 | Default is `HMSegmentedControlSelectionStyleTextWidthStripe` 130 | */ 131 | @property (nonatomic, assign) HMSegmentedControlSelectionStyle selectionStyle; 132 | 133 | /** 134 | Specifies the style of the segment's width. 135 | 136 | Default is `HMSegmentedControlSegmentWidthStyleFixed` 137 | */ 138 | @property (nonatomic, assign) HMSegmentedControlSegmentWidthStyle segmentWidthStyle; 139 | 140 | /** 141 | Specifies the location of the selection indicator. 142 | 143 | Default is `HMSegmentedControlSelectionIndicatorLocationUp` 144 | */ 145 | @property (nonatomic, assign) HMSegmentedControlSelectionIndicatorLocation selectionIndicatorLocation; 146 | 147 | /* 148 | Specifies the border type. 149 | 150 | Default is `HMSegmentedControlBorderTypeNone` 151 | */ 152 | @property (nonatomic, assign) HMSegmentedControlBorderType borderType; 153 | 154 | /** 155 | Specifies the border color. 156 | 157 | Default is `[UIColor blackColor]` 158 | */ 159 | @property (nonatomic, strong) UIColor *borderColor; 160 | 161 | /** 162 | Specifies the border width. 163 | 164 | Default is `1.0f` 165 | */ 166 | @property (nonatomic, assign) CGFloat borderWidth; 167 | 168 | /** 169 | Default is YES. Set to NO to deny scrolling by dragging the scrollView by the user. 170 | */ 171 | @property(nonatomic, getter = isUserDraggable) BOOL userDraggable; 172 | 173 | /** 174 | Default is YES. Set to NO to deny any touch events by the user. 175 | */ 176 | @property(nonatomic, getter = isTouchEnabled) BOOL touchEnabled; 177 | 178 | /** 179 | Default is NO. Set to YES to show a vertical divider between the segments. 180 | */ 181 | @property(nonatomic, getter = isVerticalDividerEnabled) BOOL verticalDividerEnabled; 182 | 183 | /** 184 | Index of the currently selected segment. 185 | */ 186 | @property (nonatomic, assign) NSInteger selectedSegmentIndex; 187 | 188 | /** 189 | Height of the selection indicator. Only effective when `HMSegmentedControlSelectionStyle` is either `HMSegmentedControlSelectionStyleTextWidthStripe` or `HMSegmentedControlSelectionStyleFullWidthStripe`. 190 | 191 | Default is 5.0 192 | */ 193 | @property (nonatomic, readwrite) CGFloat selectionIndicatorHeight; 194 | 195 | /** 196 | Edge insets for the selection indicator. 197 | NOTE: This does not affect the bounding box of HMSegmentedControlSelectionStyleBox 198 | 199 | When HMSegmentedControlSelectionIndicatorLocationUp is selected, bottom edge insets are not used 200 | 201 | When HMSegmentedControlSelectionIndicatorLocationDown is selected, top edge insets are not used 202 | 203 | Defaults are top: 0.0f 204 | left: 0.0f 205 | bottom: 0.0f 206 | right: 0.0f 207 | */ 208 | @property (nonatomic, readwrite) UIEdgeInsets selectionIndicatorEdgeInsets; 209 | 210 | /** 211 | Inset left and right edges of segments. 212 | 213 | Default is UIEdgeInsetsMake(0, 5, 0, 5) 214 | */ 215 | @property (nonatomic, readwrite) UIEdgeInsets segmentEdgeInset; 216 | 217 | /** 218 | Default is YES. Set to NO to disable animation during user selection. 219 | */ 220 | @property (nonatomic) BOOL shouldAnimateUserSelection; 221 | 222 | - (id)initWithSectionTitles:(NSArray *)sectiontitles; 223 | - (id)initWithSectionImages:(NSArray *)sectionImages sectionSelectedImages:(NSArray *)sectionSelectedImages; 224 | - (instancetype)initWithSectionImages:(NSArray *)sectionImages sectionSelectedImages:(NSArray *)sectionSelectedImages titlesForSections:(NSArray *)sectiontitles; 225 | - (void)setSelectedSegmentIndex:(NSUInteger)index animated:(BOOL)animated; 226 | - (void)setIndexChangeBlock:(IndexChangeBlock)indexChangeBlock; 227 | - (void)setTitleFormatter:(HMTitleFormatterBlock)titleFormatter; 228 | 229 | @end 230 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/BasePageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BasePageViewController.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | @class BaseViewController; 11 | @interface BasePageViewController : UIViewController 12 | @property(nonatomic,strong)NSArray * titles; 13 | @property(nonatomic,strong)NSArray * controllers; 14 | @property(nonatomic,strong)NSDictionary * titleTextAttributes; 15 | @property(nonatomic,strong)NSDictionary * selectedTitleTextAttributes; 16 | @property(nonatomic,assign)NSInteger boardType; 17 | 18 | - (instancetype)initWithPageViewFrame:(CGRect)frame; 19 | /** 20 | 添加分页 21 | */ 22 | - (void) constructData; 23 | /** 24 | 设置标题栏属性 25 | */ 26 | - (void) configSegment; 27 | 28 | /** 29 | 跳转至某页 30 | @param index 31 | */ 32 | - (void) selectPageWith:(NSInteger)index; 33 | 34 | /** 35 | 初始化分页的方法,可自行调整,但要注意page属性 36 | @param Controller 具体页面 37 | @return <#return value description#> 38 | */ 39 | - (BaseViewController*)createHomePageControllerWith:(Class)Controller; 40 | @end 41 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/BasePageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BasePageViewController.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BasePageViewController.h" 10 | #import "BaseViewController.h" 11 | #import "HMSegmentedControl.h" 12 | 13 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 14 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 15 | #define WEAK_SELF __weak typeof(self)weakSelf = self 16 | #define STRONG_SELF __strong typeof(weakSelf)self = weakSelf 17 | 18 | @interface BasePageViewController () 19 | @property(nonatomic,strong)UIPageViewController * pageView; 20 | @property(nonatomic,assign)CGRect frame; 21 | @property(nonatomic,strong)HMSegmentedControl * segment; 22 | @property(nonatomic,assign)NSInteger index; 23 | @end 24 | 25 | @implementation BasePageViewController 26 | { 27 | NSInteger _lastIndex; 28 | } 29 | -(instancetype)init 30 | { 31 | self=[super init]; 32 | if (self) { 33 | self.frame = CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT); 34 | } 35 | return self; 36 | } 37 | -(instancetype)initWithPageViewFrame:(CGRect)frame 38 | { 39 | self=[super init]; 40 | if (self) { 41 | self.frame = frame; 42 | } 43 | return self; 44 | } 45 | 46 | -(void)viewDidLoad 47 | { 48 | [super viewDidLoad]; 49 | [self constructData]; 50 | [self configSegment]; 51 | [self.view addSubview:self.pageView.view]; 52 | [self.view addSubview:self.segment]; 53 | } 54 | -(void)constructData 55 | { 56 | 57 | } 58 | -(void)configSegment 59 | { 60 | 61 | } 62 | -(UIPageViewController*)pageView 63 | { 64 | if (self.controllers.count==0) { 65 | return nil; 66 | } 67 | 68 | if (!_pageView) { 69 | _pageView=[[UIPageViewController alloc]initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil]; 70 | _pageView.view.frame = self.frame; 71 | _pageView.dataSource = self; 72 | _pageView.delegate = self; 73 | [self addChildViewController:_pageView]; 74 | [_pageView didMoveToParentViewController:self]; 75 | 76 | BaseViewController*firstVC=self.controllers[0]; 77 | [_pageView setViewControllers:@[firstVC] direction:UIPageViewControllerNavigationDirectionReverse animated:NO completion:^(BOOL finished) { 78 | firstVC.page=0; 79 | }]; 80 | } 81 | return _pageView; 82 | } 83 | 84 | -(HMSegmentedControl*)segment 85 | { 86 | if (self.controllers.count==0 || self.titles.count==0) { 87 | return nil; 88 | } 89 | if (!_segment) { 90 | _segment=[[HMSegmentedControl alloc] initWithSectionTitles:self.titles]; 91 | _segment.frame=CGRectMake(0, _pageView.view.frame.origin.y-40, SCREEN_WIDTH, 40); 92 | _segment.titleTextAttributes = self.titleTextAttributes; 93 | _segment.selectedTitleTextAttributes = self.selectedTitleTextAttributes; 94 | _segment.selectionIndicatorColor = [UIColor redColor]; 95 | _segment.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown; 96 | _segment.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleFixed; 97 | _segment.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe; 98 | _segment.selectionIndicatorHeight = 2.0f; 99 | _segment.borderType = self.boardType; 100 | _segment.borderColor = [UIColor grayColor]; 101 | _segment.borderWidth = 0.5f; 102 | 103 | WEAK_SELF; 104 | [_segment setIndexChangeBlock:^(NSInteger index) { 105 | STRONG_SELF; 106 | BaseViewController*vc=self.controllers[index]; 107 | [weakSelf.pageView setViewControllers:@[vc] direction:index>_lastIndex? UIPageViewControllerNavigationDirectionForward:UIPageViewControllerNavigationDirectionReverse animated:NO completion:^(BOOL finished) 108 | { 109 | vc.page=index; 110 | }]; 111 | 112 | }]; 113 | } 114 | return _segment; 115 | } 116 | - (void)selectPageWith:(NSInteger)index 117 | { 118 | if (index+1>self.controllers.count) 119 | { 120 | return; 121 | } 122 | 123 | if (self.segment) { 124 | [_segment setSelectedSegmentIndex:index animated:YES]; 125 | } 126 | } 127 | #pragma mark-UIPageViewDataSource 128 | - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController 129 | { 130 | BaseViewController*vc=(BaseViewController*)viewController; 131 | NSInteger index=vc.page; 132 | if ((index == 0) || (index == NSNotFound)) { 133 | return nil; 134 | } 135 | index--; 136 | return index>=self.controllers.count?nil:self.controllers[index]; 137 | } 138 | - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController 139 | { 140 | BaseViewController*vc=(BaseViewController*)viewController; 141 | NSInteger index=vc.page; 142 | if (index == NSNotFound) 143 | { 144 | return nil; 145 | } 146 | index++; 147 | if (index == self.controllers.count) 148 | { 149 | return nil; 150 | } 151 | return index>=self.controllers.count?nil:self.controllers[index]; 152 | } 153 | #pragma mark-UIPageViewDelegate 154 | 155 | - (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed 156 | { 157 | if (completed) 158 | { 159 | BaseViewController*vc=(BaseViewController*)pageViewController.viewControllers[0]; 160 | NSInteger currentPage=vc.page; 161 | vc.page = currentPage; 162 | 163 | [_segment setSelectedSegmentIndex:currentPage animated:YES]; 164 | } 165 | } 166 | 167 | -(BaseViewController*)createHomePageControllerWith:(Class)Controller 168 | { 169 | BaseViewController*page=[[Controller alloc] init]; 170 | page.view.clipsToBounds = NO; 171 | page.page=self.index; 172 | self.index++; 173 | return page; 174 | } 175 | @end 176 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/BaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseViewController : UIViewController 12 | @property(nonatomic,assign)NSInteger page; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/BaseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | @implementation BaseViewController 12 | -(void)viewDidLoad 13 | { 14 | [super viewDidLoad]; 15 | self.view.backgroundColor=[UIColor whiteColor]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/CommonPageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CommonPageViewController.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BasePageViewController.h" 10 | 11 | @interface CommonPageViewController : BasePageViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/CommonPageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CommonPageViewController.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "CommonPageViewController.h" 10 | #import "FirstController.h" 11 | #import "SecondController.h" 12 | #import "ThirdController.h" 13 | 14 | @implementation CommonPageViewController 15 | 16 | -(void)viewDidLoad 17 | { 18 | [super viewDidLoad]; 19 | } 20 | 21 | -(void)constructData 22 | { 23 | //这里设置分页数组 24 | self.controllers=@[[self createHomePageControllerWith:[FirstController class]], 25 | [self createHomePageControllerWith:[SecondController class]], 26 | [self createHomePageControllerWith:[ThirdController class]]]; 27 | } 28 | 29 | -(void)configSegment 30 | { 31 | //设置标题栏属性,需要更多属性的 可以看HMSegment里自行添加 32 | self.titles=@[@"第一页",@"第二页",@"第三页"]; 33 | 34 | self.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont systemFontOfSize:13]}; 35 | 36 | self.selectedTitleTextAttributes=@{NSForegroundColorAttributeName:[UIColor redColor], NSFontAttributeName:[UIFont systemFontOfSize:13]}; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/FirstController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FirstController.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | @interface FirstController : BaseViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/FirstController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FirstController.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "FirstController.h" 10 | 11 | @implementation FirstController 12 | -(void)viewDidLoad 13 | { 14 | [super viewDidLoad]; 15 | UILabel * label=[[UILabel alloc] initWithFrame:CGRectMake(150, 150, 200, 30)]; 16 | label.text=@"这是第一页"; 17 | label.textColor=[UIColor blueColor]; 18 | [self.view addSubview:label]; 19 | 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/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 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/SecondController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SecondController.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | @interface SecondController : BaseViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/SecondController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SecondController.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "SecondController.h" 10 | 11 | @implementation SecondController 12 | -(void)viewDidLoad 13 | { 14 | [super viewDidLoad]; 15 | UILabel * label=[[UILabel alloc] initWithFrame:CGRectMake(150, 150, 200, 30)]; 16 | label.text=@"这是第二页"; 17 | label.textColor=[UIColor blueColor]; 18 | [self.view addSubview:label]; 19 | 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/ThirdController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ThirdController.h 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | @interface ThirdController : BaseViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/ThirdController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ThirdController.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "ThirdController.h" 10 | 11 | @implementation ThirdController 12 | -(void)viewDidLoad 13 | { 14 | [super viewDidLoad]; 15 | UILabel * label=[[UILabel alloc] initWithFrame:CGRectMake(150, 150, 200, 30)]; 16 | label.text=@"这是第三页"; 17 | label.textColor=[UIColor blueColor]; 18 | [self.view addSubview:label]; 19 | 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PageViewControllerDemo 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. 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 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemoTests/PageViewControllerDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PageViewControllerDemoTests.m 3 | // PageViewControllerDemoTests 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PageViewControllerDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PageViewControllerDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PageViewControllerDemo/PageViewControllerDemoUITests/PageViewControllerDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PageViewControllerDemoUITests.m 3 | // PageViewControllerDemoUITests 4 | // 5 | // Created by 庄BB的MacBook on 16/7/29. 6 | // Copyright © 2016年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PageViewControllerDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation PageViewControllerDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS-CustomControl 2 | 一些通用的UI控件封装 3 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kazamihayato/iOS-CustomControl/0ba00e5d7e134ab09c1063163a92d217a7cbce72/TopViewDemo/TopViewDemo.xcodeproj/project.xcworkspace/xcuserdata/ZBB.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo.xcodeproj/xcuserdata/ZBB.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | TopViewDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. 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 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. 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 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/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 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/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 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/BBTopView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BBTopView.h 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BBTopView : UIView 12 | 13 | typedef NS_ENUM(NSInteger, NoticeType) { 14 | Success, 15 | Fail, 16 | Warning 17 | }; 18 | 19 | +(void) showTopSuccess:(NSString*)successInfo; 20 | 21 | +(void) showTopFailed:(NSString*)failedInfo; 22 | 23 | +(void) showTopWarning:(NSString*)warningInfo; 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/BBTopView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BBTopView.m 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "BBTopView.h" 10 | #import "UIFont+FontAwesome.h" 11 | #import "NSString+FontAwesome.h" 12 | 13 | #define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width 14 | #define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height 15 | 16 | #define SuccessColor [UIColor colorWithRed:47/255.0f green:204/255.0f blue:112/255.0f alpha:1] 17 | #define FailColor [UIColor colorWithRed:232/255.0f green:78/255.0f blue:60/255.0f alpha:1] 18 | #define WaringColor [UIColor colorWithRed:230.0f/255.0f green:95.0f/255.0f blue:7.0f/255.0f alpha:1] 19 | 20 | static const CGFloat waringHeight = 64.0f; 21 | static const CGFloat AlertWidth = 270.0f; 22 | static const CGFloat AlertGap = 10.0f; 23 | 24 | @interface BBTopView () 25 | @property(nonatomic,strong)UILabel * titleLabel; 26 | @property(nonatomic,strong)UILabel * messageLabel; 27 | @property(nonatomic,strong)NSString * state; 28 | @property(nonatomic,strong)UIColor * infoColor; 29 | @end 30 | 31 | @implementation BBTopView 32 | 33 | +(void)showTopSuccess:(NSString *)successInfo 34 | { 35 | BBTopView*topView=[[BBTopView alloc] initTopViewWithNoticeType:Success noticeInfo:successInfo]; 36 | [topView show]; 37 | } 38 | 39 | +(void)showTopFailed:(NSString *)failedInfo 40 | { 41 | BBTopView*topView=[[BBTopView alloc] initTopViewWithNoticeType:Fail noticeInfo:failedInfo]; 42 | [topView show]; 43 | } 44 | 45 | +(void)showTopWarning:(NSString *)warningInfo 46 | { 47 | BBTopView*topView=[[BBTopView alloc] initTopViewWithNoticeType:Warning noticeInfo:warningInfo]; 48 | [UIColor whiteColor]; 49 | [topView show]; 50 | } 51 | 52 | -(instancetype)initTopViewWithNoticeType:(NoticeType)noticeType 53 | noticeInfo:(NSString *)noticeInfo 54 | { 55 | self=[super init]; 56 | if (self) { 57 | 58 | switch (noticeType) { 59 | case Success: 60 | { 61 | self.state = [NSString fontAwesomeIconStringForEnum:FACheckCircle]; 62 | self.infoColor = SuccessColor; 63 | } 64 | break; 65 | case Fail: 66 | { 67 | self.state = [NSString fontAwesomeIconStringForEnum:FATimesCircle]; 68 | self.infoColor = FailColor; 69 | } 70 | break; 71 | case Warning: 72 | { 73 | self.state = [NSString fontAwesomeIconStringForEnum:FAExclamationCircle]; 74 | self.infoColor = WaringColor; 75 | } 76 | break; 77 | default: 78 | break; 79 | } 80 | [self createTopViewWithNoticeInfo:noticeInfo]; 81 | 82 | } 83 | return self; 84 | } 85 | 86 | -(void)createTopViewWithNoticeInfo:(NSString *)noticeInfo 87 | { 88 | self.frame = CGRectMake(0, -waringHeight, SCREEN_WIDTH,waringHeight); 89 | self.backgroundColor = self.infoColor; 90 | self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(2*AlertGap, 4, waringHeight-30, waringHeight)]; 91 | self.titleLabel.backgroundColor = [UIColor clearColor]; 92 | self.titleLabel.textColor = [UIColor whiteColor]; 93 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 94 | self.titleLabel.font = [UIFont fontAwesomeFontOfSize:35]; 95 | self.titleLabel.text = self.state; 96 | self.titleLabel.layer.opacity = 0; 97 | 98 | [self addSubview:self.titleLabel]; 99 | 100 | CGFloat infoHeight = [self heightWithString:noticeInfo fontSize:15 width:AlertWidth]; 101 | 102 | self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.titleLabel.frame), (waringHeight-infoHeight)/2+5, SCREEN_WIDTH-CGRectGetMaxX(self.titleLabel.frame)*2, infoHeight)]; 103 | self.messageLabel.text = noticeInfo; 104 | self.messageLabel.textColor = [UIColor whiteColor]; 105 | self.messageLabel.textAlignment = NSTextAlignmentCenter; 106 | self.messageLabel.font = [UIFont boldSystemFontOfSize:15]; 107 | 108 | [self addSubview:self.messageLabel]; 109 | } 110 | 111 | -(void)show 112 | { 113 | [[UIApplication sharedApplication].keyWindow addSubview:self]; 114 | [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:1 options:UIViewAnimationOptionCurveLinear animations:^{ 115 | 116 | self.frame = CGRectMake(0, 0, SCREEN_WIDTH,waringHeight); 117 | 118 | } completion:^(BOOL finished) { 119 | 120 | self.titleLabel.layer.opacity = 1; 121 | self.titleLabel.transform = CGAffineTransformMakeScale(0, 0); 122 | 123 | [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:1 options:UIViewAnimationOptionCurveLinear animations:^{ 124 | 125 | self.titleLabel.transform = CGAffineTransformMakeScale(1, 1); 126 | 127 | } completion:^(BOOL finished) { 128 | 129 | }]; 130 | }]; 131 | [self performSelector:@selector(dismiss) withObject:nil afterDelay:2.0]; 132 | } 133 | -(void)dismiss 134 | { 135 | [UIView animateWithDuration:0.3 animations:^{ 136 | 137 | self.center=CGPointMake(CGRectGetMidX(self.frame), self.frame.origin.y-waringHeight); 138 | 139 | } completion:^(BOOL finished) { 140 | [self removeFromSuperview]; 141 | }]; 142 | } 143 | 144 | -(CGFloat)heightWithString:(NSString*)string fontSize:(CGFloat)fontSize width:(CGFloat)width 145 | { 146 | NSDictionary *attrs = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]}; 147 | return [string boundingRectWithSize:CGSizeMake(width, 0) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attrs context:nil].size.height; 148 | } 149 | 150 | @end 151 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/fontawesome/FAImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FAImageView.h 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/24. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSString+FontAwesome.h" 11 | 12 | @interface FAImageView : UIImageView 13 | /* The background color for the default view displayed when the image is missing */ 14 | @property (nonatomic, strong) UIColor *defaultIconColor UI_APPEARANCE_SELECTOR; 15 | 16 | /* Set the icon using the fontawesome icon's identifier */ 17 | @property (nonatomic, strong) NSString *defaultIconIdentifier; 18 | 19 | /* Set the icon using the icon enumerations */ 20 | @property (nonatomic, assign) FAIcon defaultIcon; 21 | 22 | /* The view that is displayed when the image is set to nil */ 23 | @property (nonatomic, strong) UILabel *defaultView; 24 | @end 25 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/fontawesome/FAImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FAImageView.m 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/24. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "FAImageView.h" 10 | #import "UIFont+FontAwesome.h" 11 | 12 | @implementation FAImageView 13 | 14 | /* When the image is set to nil the defaultView will be added as subview, 15 | * otherwise it will be removed */ 16 | - (void)setImage:(UIImage*)image 17 | { 18 | [super setImage:image]; 19 | self.defaultView.hidden = (nil != image); 20 | } 21 | 22 | #pragma mark - Toggle the icon view 23 | 24 | /* Lazy initialization of the view */ 25 | - (UILabel*)defaultView 26 | { 27 | if (nil != _defaultView) 28 | return _defaultView; 29 | 30 | //The size of the default view is the same of self 31 | _defaultView = [[UILabel alloc] initWithFrame:self.bounds]; 32 | _defaultView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 33 | 34 | //The default icon is the ban icon 35 | [self setDefaultIcon:FABan]; 36 | 37 | _defaultView.font = [UIFont fontAwesomeFontOfSize:self.bounds.size.height]; 38 | _defaultView.textAlignment = NSTextAlignmentCenter; 39 | _defaultView.adjustsFontSizeToFitWidth = YES; 40 | 41 | //UIAppearance selectors 42 | _defaultView.textColor = [UIColor whiteColor]; 43 | _defaultView.backgroundColor = [UIColor colorWithRed:.9f green:.9f blue:.9f alpha:1.f]; 44 | 45 | //It starts hidden 46 | _defaultView.hidden = YES; 47 | 48 | [self addSubview:_defaultView]; 49 | 50 | return _defaultView; 51 | } 52 | 53 | #pragma mark - Properties 54 | 55 | - (void)setDefaultIconIdentifier:(NSString*)defaultIconIdentifier 56 | { 57 | self.defaultIcon = [NSString fontAwesomeEnumForIconIdentifier:defaultIconIdentifier]; 58 | } 59 | 60 | - (void)setDefaultIcon:(FAIcon)defaultIcon 61 | { 62 | _defaultIcon = defaultIcon; 63 | _defaultView.text = [NSString fontAwesomeIconStringForEnum:defaultIcon]; 64 | } 65 | @end 66 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/fontawesome/FontAwesome.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kazamihayato/iOS-CustomControl/0ba00e5d7e134ab09c1063163a92d217a7cbce72/TopViewDemo/TopViewDemo/Class/fontawesome/FontAwesome.ttf -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/fontawesome/NSString+FontAwesome.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+FontAwesome.h 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/24. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | static NSString *const kFontAwesomeFamilyName = @"FontAwesome"; 12 | 13 | /** 14 | @abstract FontAwesome Icons. 15 | */ 16 | typedef NS_ENUM(NSInteger, FAIcon) { 17 | FAGlass, 18 | FAMusic, 19 | FASearch, 20 | FAEnvelopeO, 21 | FAHeart, 22 | FAStar, 23 | FAStarO, 24 | FAUser, 25 | FAFilm, 26 | FAThLarge, 27 | FATh, 28 | FAThList, 29 | FACheck, 30 | FATimes, 31 | FASearchPlus, 32 | FASearchMinus, 33 | FAPowerOff, 34 | FASignal, 35 | FACog, 36 | FATrashO, 37 | FAHome, 38 | FAFileO, 39 | FAClockO, 40 | FARoad, 41 | FADownload, 42 | FAArrowCircleODown, 43 | FAArrowCircleOUp, 44 | FAInbox, 45 | FAPlayCircleO, 46 | FARepeat, 47 | FARefresh, 48 | FAListAlt, 49 | FALock, 50 | FAFlag, 51 | FAHeadphones, 52 | FAVolumeOff, 53 | FAVolumeDown, 54 | FAVolumeUp, 55 | FAQrcode, 56 | FABarcode, 57 | FATag, 58 | FATags, 59 | FABook, 60 | FABookmark, 61 | FAPrint, 62 | FACamera, 63 | FAFont, 64 | FABold, 65 | FAItalic, 66 | FATextHeight, 67 | FATextWidth, 68 | FAAlignLeft, 69 | FAAlignCenter, 70 | FAAlignRight, 71 | FAAlignJustify, 72 | FAList, 73 | FAOutdent, 74 | FAIndent, 75 | FAVideoCamera, 76 | FAPictureO, 77 | FAPencil, 78 | FAMapMarker, 79 | FAAdjust, 80 | FATint, 81 | FAPencilSquareO, 82 | FAShareSquareO, 83 | FACheckSquareO, 84 | FAArrows, 85 | FAStepBackward, 86 | FAFastBackward, 87 | FABackward, 88 | FAPlay, 89 | FAPause, 90 | FAStop, 91 | FAForward, 92 | FAFastForward, 93 | FAStepForward, 94 | FAEject, 95 | FAChevronLeft, 96 | FAChevronRight, 97 | FAPlusCircle, 98 | FAMinusCircle, 99 | FATimesCircle, 100 | FACheckCircle, 101 | FAQuestionCircle, 102 | FAInfoCircle, 103 | FACrosshairs, 104 | FATimesCircleO, 105 | FACheckCircleO, 106 | FABan, 107 | FAArrowLeft, 108 | FAArrowRight, 109 | FAArrowUp, 110 | FAArrowDown, 111 | FAShare, 112 | FAExpand, 113 | FACompress, 114 | FAPlus, 115 | FAMinus, 116 | FAAsterisk, 117 | FAExclamationCircle, 118 | FAGift, 119 | FALeaf, 120 | FAFire, 121 | FAEye, 122 | FAEyeSlash, 123 | FAExclamationTriangle, 124 | FAPlane, 125 | FACalendar, 126 | FARandom, 127 | FAComment, 128 | FAMagnet, 129 | FAChevronUp, 130 | FAChevronDown, 131 | FARetweet, 132 | FAShoppingCart, 133 | FAFolder, 134 | FAFolderOpen, 135 | FAArrowsV, 136 | FAArrowsH, 137 | FABarChartO, 138 | FATwitterSquare, 139 | FAFacebookSquare, 140 | FACameraRetro, 141 | FAKey, 142 | FACogs, 143 | FAComments, 144 | FAThumbsOUp, 145 | FAThumbsODown, 146 | FAStarHalf, 147 | FAHeartO, 148 | FASignOut, 149 | FALinkedinSquare, 150 | FAThumbTack, 151 | FAExternalLink, 152 | FASignIn, 153 | FATrophy, 154 | FAGithubSquare, 155 | FAUpload, 156 | FALemonO, 157 | FAPhone, 158 | FASquareO, 159 | FABookmarkO, 160 | FAPhoneSquare, 161 | FATwitter, 162 | FAFacebook, 163 | FAGithub, 164 | FAUnlock, 165 | FACreditCard, 166 | FARss, 167 | FAHddO, 168 | FABullhorn, 169 | FABell, 170 | FACertificate, 171 | FAHandORight, 172 | FAHandOLeft, 173 | FAHandOUp, 174 | FAHandODown, 175 | FAArrowCircleLeft, 176 | FAArrowCircleRight, 177 | FAArrowCircleUp, 178 | FAArrowCircleDown, 179 | FAGlobe, 180 | FAWrench, 181 | FATasks, 182 | FAFilter, 183 | FABriefcase, 184 | FAArrowsAlt, 185 | FAUsers, 186 | FALink, 187 | FACloud, 188 | FAFlask, 189 | FAScissors, 190 | FAFilesO, 191 | FAPaperclip, 192 | FAFloppyO, 193 | FASquare, 194 | FABars, 195 | FAListUl, 196 | FAListOl, 197 | FAStrikethrough, 198 | FAUnderline, 199 | FATable, 200 | FAMagic, 201 | FATruck, 202 | FAPinterest, 203 | FAPinterestSquare, 204 | FAGooglePlusSquare, 205 | FAGooglePlus, 206 | FAMoney, 207 | FACaretDown, 208 | FACaretUp, 209 | FACaretLeft, 210 | FACaretRight, 211 | FAColumns, 212 | FASort, 213 | FASortAsc, 214 | FASortDesc, 215 | FAEnvelope, 216 | FALinkedin, 217 | FAUndo, 218 | FAGavel, 219 | FATachometer, 220 | FACommentO, 221 | FACommentsO, 222 | FABolt, 223 | FASitemap, 224 | FAUmbrella, 225 | FAClipboard, 226 | FALightbulbO, 227 | FAExchange, 228 | FACloudDownload, 229 | FACloudUpload, 230 | FAUserMd, 231 | FAStethoscope, 232 | FASuitcase, 233 | FABellO, 234 | FACoffee, 235 | FACutlery, 236 | FAFileTextO, 237 | FABuildingO, 238 | FAHospitalO, 239 | FAAmbulance, 240 | FAMedkit, 241 | FAFighterJet, 242 | FABeer, 243 | FAHSquare, 244 | FAPlusSquare, 245 | FAAngleDoubleLeft, 246 | FAAngleDoubleRight, 247 | FAAngleDoubleUp, 248 | FAAngleDoubleDown, 249 | FAAngleLeft, 250 | FAAngleRight, 251 | FAAngleUp, 252 | FAAngleDown, 253 | FADesktop, 254 | FALaptop, 255 | FATablet, 256 | FAMobile, 257 | FACircleO, 258 | FAQuoteLeft, 259 | FAQuoteRight, 260 | FASpinner, 261 | FACircle, 262 | FAReply, 263 | FAGithubAlt, 264 | FAFolderO, 265 | FAFolderOpenO, 266 | FASmileO, 267 | FAFrownO, 268 | FAMehO, 269 | FAGamepad, 270 | FAKeyboardO, 271 | FAFlagO, 272 | FAFlagCheckered, 273 | FATerminal, 274 | FACode, 275 | FAReplyAll, 276 | FAMailReplyAll, 277 | FAStarHalfO, 278 | FALocationArrow, 279 | FACrop, 280 | FACodeFork, 281 | FAChainBroken, 282 | FAQuestion, 283 | FAInfo, 284 | FAExclamation, 285 | FASuperscript, 286 | FASubscript, 287 | FAEraser, 288 | FAPuzzlePiece, 289 | FAMicrophone, 290 | FAMicrophoneSlash, 291 | FAShield, 292 | FACalendarO, 293 | FAFireExtinguisher, 294 | FARocket, 295 | FAMaxcdn, 296 | FAChevronCircleLeft, 297 | FAChevronCircleRight, 298 | FAChevronCircleUp, 299 | FAChevronCircleDown, 300 | FAHtml5, 301 | FACss3, 302 | FAAnchor, 303 | FAUnlockAlt, 304 | FABullseye, 305 | FAEllipsisH, 306 | FAEllipsisV, 307 | FARssSquare, 308 | FAPlayCircle, 309 | FATicket, 310 | FAMinusSquare, 311 | FAMinusSquareO, 312 | FALevelUp, 313 | FALevelDown, 314 | FACheckSquare, 315 | FAPencilSquare, 316 | FAExternalLinkSquare, 317 | FAShareSquare, 318 | FACompass, 319 | FACaretSquareODown, 320 | FACaretSquareOUp, 321 | FACaretSquareORight, 322 | FAEur, 323 | FAGbp, 324 | FAUsd, 325 | FAInr, 326 | FAJpy, 327 | FARub, 328 | FAKrw, 329 | FABtc, 330 | FAFile, 331 | FAFileText, 332 | FASortAlphaAsc, 333 | FASortAlphaDesc, 334 | FASortAmountAsc, 335 | FASortAmountDesc, 336 | FASortNumericAsc, 337 | FASortNumericDesc, 338 | FAThumbsUp, 339 | FAThumbsDown, 340 | FAYoutubeSquare, 341 | FAYoutube, 342 | FAXing, 343 | FAXingSquare, 344 | FAYoutubePlay, 345 | FADropbox, 346 | FAStackOverflow, 347 | FAInstagram, 348 | FAFlickr, 349 | FAAdn, 350 | FABitbucket, 351 | FABitbucketSquare, 352 | FATumblr, 353 | FATumblrSquare, 354 | FALongArrowDown, 355 | FALongArrowUp, 356 | FALongArrowLeft, 357 | FALongArrowRight, 358 | FAApple, 359 | FAWindows, 360 | FAAndroid, 361 | FALinux, 362 | FADribbble, 363 | FASkype, 364 | FAFoursquare, 365 | FATrello, 366 | FAFemale, 367 | FAMale, 368 | FAGittip, 369 | FASunO, 370 | FAMoonO, 371 | FAArchive, 372 | FABug, 373 | FAVk, 374 | FAWeibo, 375 | FARenren, 376 | FAPagelines, 377 | FAStackExchange, 378 | FAArrowCircleORight, 379 | FAArrowCircleOLeft, 380 | FACaretSquareOLeft, 381 | FADotCircleO, 382 | FAWheelchair, 383 | FAVimeoSquare, 384 | FATry, 385 | FAPlusSquareO, 386 | 387 | /* FontAwesome ver 4.1.0 */ 388 | FAautomobile, 389 | FAbank, 390 | FAbehance, 391 | FAbehanceSquare, 392 | FAbomb, 393 | FAbuilding, 394 | FAcab, 395 | FAcar, 396 | FAchild, 397 | FAcircleONotch, 398 | FAcircleThin, 399 | FAcodepen, 400 | FAcube, 401 | FAcubes, 402 | FAdatabase, 403 | FAdelicious, 404 | FAdeviantart, 405 | FAdigg, 406 | FAdrupal, 407 | FAempire, 408 | FAenvelopeSquare, 409 | FAfax, 410 | FAfileArchiveO, 411 | FAfileAudioO, 412 | FAfileCodeO, 413 | FAfileExcelO, 414 | FAfileImageO, 415 | FAfileMovieO, 416 | FAfilePdfO, 417 | FAfilePhotoO, 418 | FAfilePictureO, 419 | FAfilePowerpointO, 420 | FAfileSoundO, 421 | FAfileVideoO, 422 | FAfileWordO, 423 | FAfileZipO, 424 | FAge, 425 | FAgit, 426 | FAgitSquare, 427 | FAgoogle, 428 | FAgraduationCap, 429 | FAhackerNews, 430 | FAheader, 431 | FAhistory, 432 | FAinstitution, 433 | FAjoomla, 434 | FAjsfiddle, 435 | FAlanguage, 436 | FAlifeBouy, 437 | FAlifeRing, 438 | FAlifeSaver, 439 | FAmortarBoard, 440 | FAopenid, 441 | FApaperPlane, 442 | FApaperPlaneO, 443 | FAparagraph, 444 | FApaw, 445 | FApiedPiper, 446 | FApiedPiperalt, 447 | FApiedPipersquare, 448 | FAqq, 449 | FAra, 450 | FArebel, 451 | FArecycle, 452 | FAreddit, 453 | FAredditSquare, 454 | FAsend, 455 | FAsendO, 456 | FAshareAlt, 457 | FAshareAltSquare, 458 | FAslack, 459 | FAsliders, 460 | FAsoundcloud, 461 | FAspaceShuttle, 462 | FAspoon, 463 | FAspotify, 464 | FAsteam, 465 | FAsteamSquare, 466 | FAstumbleupon, 467 | FAstumbleuponCircle, 468 | FAsupport, 469 | FAtaxi, 470 | FAtencentWeibo, 471 | FAtree, 472 | FAuniversity, 473 | FAvine, 474 | FAwechat, 475 | FAweixin, 476 | FAwordpress, 477 | FAyahoo, 478 | 479 | /* FontAwesome ver 4.2.0 */ 480 | FAangellist, 481 | FAareaChart, 482 | FAat, 483 | FAbellSlash, 484 | FAbellSlashO, 485 | FAbicycle, 486 | FAbinoculars, 487 | FAbirthdayCake, 488 | FAbus, 489 | FAcalculator, 490 | FAcc, 491 | FAccAmex, 492 | FAccDiscover, 493 | FAccMastercard, 494 | FAccPaypal, 495 | FAccStripe, 496 | FAccVisa, 497 | FAcopyright, 498 | FAeyedropper, 499 | FAfutbolO, 500 | FAgoogleWallet, 501 | FAils, 502 | FAioxhost, 503 | FAlastfm, 504 | FAlastfmSquare, 505 | FAlineChart, 506 | FAmeanpath, 507 | FAnewspaperO, 508 | FApaintBrush, 509 | FApaypal, 510 | FApieChart, 511 | FAplug, 512 | FAshekel, 513 | FAsheqel, 514 | FAslideshare, 515 | FAsoccerBallO, 516 | FAtoggleOff, 517 | FAtoggleOn, 518 | FAtrash, 519 | FAtty, 520 | FAtwitch, 521 | FAwifi, 522 | FAyelp, 523 | }; 524 | 525 | 526 | 527 | @interface NSString (FontAwesome) 528 | 529 | /** 530 | @abstract Returns the correct enum for a font-awesome icon. 531 | @discussion The list of identifiers can be found here: http://fortawesome.github.com/Font-Awesome/#all-icons 532 | */ 533 | + (FAIcon)fontAwesomeEnumForIconIdentifier:(NSString*)string; 534 | 535 | /** 536 | @abstract Returns the font-awesome character associated to the icon enum passed as argument 537 | */ 538 | + (NSString*)fontAwesomeIconStringForEnum:(FAIcon)value; 539 | 540 | /* 541 | @abstract Returns the font-awesome character associated to the font-awesome identifier. 542 | @discussion The list of identifiers can be found here: http://fortawesome.github.com/Font-Awesome/#all-icons 543 | */ 544 | + (NSString*)fontAwesomeIconStringForIconIdentifier:(NSString*)identifier; 545 | 546 | @end 547 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/fontawesome/UIFont+FontAwesome.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIFont+FontAwesome.h 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/24. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIFont (FontAwesome) 12 | /** 13 | @abstract Returns the FontAwesome iconic font. 14 | */ 15 | + (UIFont*)fontAwesomeFontOfSize:(CGFloat)size; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Class/fontawesome/UIFont+FontAwesome.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIFont+FontAwesome.m 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/24. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "UIFont+FontAwesome.h" 10 | #import "NSString+FontAwesome.h" 11 | 12 | @implementation UIFont (FontAwesome) 13 | #pragma mark - Public API 14 | + (UIFont*)fontAwesomeFontOfSize:(CGFloat)size { 15 | return [UIFont fontWithName:kFontAwesomeFamilyName size:size]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIAppFonts 6 | 7 | FontAwesome.ttf 8 | 9 | CFBundleDevelopmentRegion 10 | $(DEVELOPMENT_LANGUAGE) 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BBTopView.h" 11 | 12 | #define Titles [NSArray arrayWithObjects:@"成功",@"失败",@"警告",nil] 13 | 14 | 15 | @interface ViewController () 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | [Titles enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 25 | 26 | UIButton * btn = [UIButton buttonWithType:UIButtonTypeSystem]; 27 | btn.frame = CGRectMake(([[UIScreen mainScreen] bounds].size.width-250)/2, 120*(idx+1)+30*idx, 250, 30); 28 | btn.tag = 100+idx; 29 | [btn setTitle :(NSString*)obj forState:UIControlStateNormal]; 30 | [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside]; 31 | [self.view addSubview:btn]; 32 | 33 | }]; 34 | // Do any additional setup after loading the view, typically from a nib. 35 | } 36 | 37 | -(void)btnPressed:(UIButton*)btn 38 | { 39 | switch (btn.tag-100) { 40 | case 0: 41 | { 42 | [BBTopView showTopSuccess:@"发布成功"]; 43 | } 44 | break; 45 | case 1: 46 | { 47 | [BBTopView showTopFailed:@"发布失败"]; 48 | } 49 | break; 50 | case 2: 51 | { 52 | [BBTopView showTopWarning:@"网络似乎出了点状况"]; 53 | } 54 | break; 55 | default: 56 | break; 57 | } 58 | } 59 | 60 | - (void)didReceiveMemoryWarning { 61 | [super didReceiveMemoryWarning]; 62 | // Dispose of any resources that can be recreated. 63 | } 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TopViewDemo 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. 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 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TopViewDemo/TopViewDemoUITests/TopViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TopViewDemoUITests.m 3 | // TopViewDemoUITests 4 | // 5 | // Created by 庄BB的MacBook on 2017/10/20. 6 | // Copyright © 2017年 BBFC. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TopViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation TopViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------