├── .gitignore ├── CustomViewSample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── CustomViewSample.xccheckout └── xcuserdata │ ├── himara2.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── CustomViewSample.xcscheme │ │ └── xcschememanagement.plist │ └── rhiramat.xcuserdatad │ └── xcschemes │ ├── CustomViewSample.xcscheme │ └── xcschememanagement.plist ├── CustomViewSample ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── alpaca_icon.imageset │ │ ├── Contents.json │ │ └── alpaca_icon.png │ ├── profile_icon.imageset │ │ ├── Contents.json │ │ └── profile_icon.png │ └── startbutton_bg.imageset │ │ ├── Contents.json │ │ └── startbutton_bg@2x.png ├── Info.plist ├── MyCustomView.swift ├── MyCustomView.xib ├── ViewController.swift └── XibInstantiatable.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.ipa 2 | *xcuserdata 3 | *.xcuserstate 4 | xcuserstate 5 | Pods/ 6 | Podfile.lock 7 | *.zip 8 | build/* 9 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 201FD75A1B62502000963F08 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201FD7591B62502000963F08 /* AppDelegate.swift */; }; 11 | 201FD75C1B62502000963F08 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201FD75B1B62502000963F08 /* ViewController.swift */; }; 12 | 201FD75F1B62502000963F08 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 201FD75D1B62502000963F08 /* Main.storyboard */; }; 13 | 201FD7611B62502000963F08 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 201FD7601B62502000963F08 /* Images.xcassets */; }; 14 | 201FD7641B62502000963F08 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 201FD7621B62502000963F08 /* LaunchScreen.xib */; }; 15 | 201FD77B1B62509200963F08 /* MyCustomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201FD77A1B62509200963F08 /* MyCustomView.swift */; }; 16 | 201FD77D1B62509C00963F08 /* MyCustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 201FD77C1B62509C00963F08 /* MyCustomView.xib */; }; 17 | D9CDED891DC17BB8001CF3D3 /* XibInstantiatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9CDED881DC17BB8001CF3D3 /* XibInstantiatable.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 201FD7541B62502000963F08 /* CustomViewSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomViewSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 201FD7581B62502000963F08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | 201FD7591B62502000963F08 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | 201FD75B1B62502000963F08 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | 201FD75E1B62502000963F08 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 201FD7601B62502000963F08 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 27 | 201FD7631B62502000963F08 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 28 | 201FD77A1B62509200963F08 /* MyCustomView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyCustomView.swift; sourceTree = ""; }; 29 | 201FD77C1B62509C00963F08 /* MyCustomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyCustomView.xib; sourceTree = ""; }; 30 | D9CDED881DC17BB8001CF3D3 /* XibInstantiatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XibInstantiatable.swift; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 201FD7511B62502000963F08 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 201FD74B1B62502000963F08 = { 45 | isa = PBXGroup; 46 | children = ( 47 | 201FD7561B62502000963F08 /* CustomViewSample */, 48 | 201FD7551B62502000963F08 /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | 201FD7551B62502000963F08 /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 201FD7541B62502000963F08 /* CustomViewSample.app */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | 201FD7561B62502000963F08 /* CustomViewSample */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | D9CDED871DC17B9D001CF3D3 /* Extension */, 64 | 201FD7791B62502C00963F08 /* CustomView */, 65 | 201FD7591B62502000963F08 /* AppDelegate.swift */, 66 | 201FD75B1B62502000963F08 /* ViewController.swift */, 67 | 201FD75D1B62502000963F08 /* Main.storyboard */, 68 | 201FD7601B62502000963F08 /* Images.xcassets */, 69 | 201FD7621B62502000963F08 /* LaunchScreen.xib */, 70 | 201FD7571B62502000963F08 /* Supporting Files */, 71 | ); 72 | path = CustomViewSample; 73 | sourceTree = ""; 74 | }; 75 | 201FD7571B62502000963F08 /* Supporting Files */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 201FD7581B62502000963F08 /* Info.plist */, 79 | ); 80 | name = "Supporting Files"; 81 | sourceTree = ""; 82 | }; 83 | 201FD7791B62502C00963F08 /* CustomView */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 201FD77A1B62509200963F08 /* MyCustomView.swift */, 87 | 201FD77C1B62509C00963F08 /* MyCustomView.xib */, 88 | ); 89 | name = CustomView; 90 | sourceTree = ""; 91 | }; 92 | D9CDED871DC17B9D001CF3D3 /* Extension */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | D9CDED881DC17BB8001CF3D3 /* XibInstantiatable.swift */, 96 | ); 97 | name = Extension; 98 | sourceTree = ""; 99 | }; 100 | /* End PBXGroup section */ 101 | 102 | /* Begin PBXNativeTarget section */ 103 | 201FD7531B62502000963F08 /* CustomViewSample */ = { 104 | isa = PBXNativeTarget; 105 | buildConfigurationList = 201FD7731B62502100963F08 /* Build configuration list for PBXNativeTarget "CustomViewSample" */; 106 | buildPhases = ( 107 | 201FD7501B62502000963F08 /* Sources */, 108 | 201FD7511B62502000963F08 /* Frameworks */, 109 | 201FD7521B62502000963F08 /* Resources */, 110 | ); 111 | buildRules = ( 112 | ); 113 | dependencies = ( 114 | ); 115 | name = CustomViewSample; 116 | productName = CustomViewSample; 117 | productReference = 201FD7541B62502000963F08 /* CustomViewSample.app */; 118 | productType = "com.apple.product-type.application"; 119 | }; 120 | /* End PBXNativeTarget section */ 121 | 122 | /* Begin PBXProject section */ 123 | 201FD74C1B62502000963F08 /* Project object */ = { 124 | isa = PBXProject; 125 | attributes = { 126 | LastSwiftMigration = 0730; 127 | LastSwiftUpdateCheck = 0730; 128 | LastUpgradeCheck = 0630; 129 | ORGANIZATIONNAME = himara2; 130 | TargetAttributes = { 131 | 201FD7531B62502000963F08 = { 132 | CreatedOnToolsVersion = 6.3; 133 | LastSwiftMigration = 0800; 134 | }; 135 | }; 136 | }; 137 | buildConfigurationList = 201FD74F1B62502000963F08 /* Build configuration list for PBXProject "CustomViewSample" */; 138 | compatibilityVersion = "Xcode 3.2"; 139 | developmentRegion = English; 140 | hasScannedForEncodings = 0; 141 | knownRegions = ( 142 | en, 143 | Base, 144 | ); 145 | mainGroup = 201FD74B1B62502000963F08; 146 | productRefGroup = 201FD7551B62502000963F08 /* Products */; 147 | projectDirPath = ""; 148 | projectRoot = ""; 149 | targets = ( 150 | 201FD7531B62502000963F08 /* CustomViewSample */, 151 | ); 152 | }; 153 | /* End PBXProject section */ 154 | 155 | /* Begin PBXResourcesBuildPhase section */ 156 | 201FD7521B62502000963F08 /* Resources */ = { 157 | isa = PBXResourcesBuildPhase; 158 | buildActionMask = 2147483647; 159 | files = ( 160 | 201FD75F1B62502000963F08 /* Main.storyboard in Resources */, 161 | 201FD77D1B62509C00963F08 /* MyCustomView.xib in Resources */, 162 | 201FD7641B62502000963F08 /* LaunchScreen.xib in Resources */, 163 | 201FD7611B62502000963F08 /* Images.xcassets in Resources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXResourcesBuildPhase section */ 168 | 169 | /* Begin PBXSourcesBuildPhase section */ 170 | 201FD7501B62502000963F08 /* Sources */ = { 171 | isa = PBXSourcesBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | D9CDED891DC17BB8001CF3D3 /* XibInstantiatable.swift in Sources */, 175 | 201FD75C1B62502000963F08 /* ViewController.swift in Sources */, 176 | 201FD77B1B62509200963F08 /* MyCustomView.swift in Sources */, 177 | 201FD75A1B62502000963F08 /* AppDelegate.swift in Sources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXSourcesBuildPhase section */ 182 | 183 | /* Begin PBXVariantGroup section */ 184 | 201FD75D1B62502000963F08 /* Main.storyboard */ = { 185 | isa = PBXVariantGroup; 186 | children = ( 187 | 201FD75E1B62502000963F08 /* Base */, 188 | ); 189 | name = Main.storyboard; 190 | sourceTree = ""; 191 | }; 192 | 201FD7621B62502000963F08 /* LaunchScreen.xib */ = { 193 | isa = PBXVariantGroup; 194 | children = ( 195 | 201FD7631B62502000963F08 /* Base */, 196 | ); 197 | name = LaunchScreen.xib; 198 | sourceTree = ""; 199 | }; 200 | /* End PBXVariantGroup section */ 201 | 202 | /* Begin XCBuildConfiguration section */ 203 | 201FD7711B62502100963F08 /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_CXX_LIBRARY = "libc++"; 209 | CLANG_ENABLE_MODULES = YES; 210 | CLANG_ENABLE_OBJC_ARC = YES; 211 | CLANG_WARN_BOOL_CONVERSION = YES; 212 | CLANG_WARN_CONSTANT_CONVERSION = YES; 213 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INT_CONVERSION = YES; 217 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 218 | CLANG_WARN_UNREACHABLE_CODE = YES; 219 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 220 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 221 | COPY_PHASE_STRIP = NO; 222 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 223 | ENABLE_STRICT_OBJC_MSGSEND = YES; 224 | GCC_C_LANGUAGE_STANDARD = gnu99; 225 | GCC_DYNAMIC_NO_PIC = NO; 226 | GCC_NO_COMMON_BLOCKS = YES; 227 | GCC_OPTIMIZATION_LEVEL = 0; 228 | GCC_PREPROCESSOR_DEFINITIONS = ( 229 | "DEBUG=1", 230 | "$(inherited)", 231 | ); 232 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 240 | MTL_ENABLE_DEBUG_INFO = YES; 241 | ONLY_ACTIVE_ARCH = YES; 242 | SDKROOT = iphoneos; 243 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 244 | }; 245 | name = Debug; 246 | }; 247 | 201FD7721B62502100963F08 /* Release */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ALWAYS_SEARCH_USER_PATHS = NO; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_WARN_BOOL_CONVERSION = YES; 256 | CLANG_WARN_CONSTANT_CONVERSION = YES; 257 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 258 | CLANG_WARN_EMPTY_BODY = YES; 259 | CLANG_WARN_ENUM_CONVERSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 262 | CLANG_WARN_UNREACHABLE_CODE = YES; 263 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 264 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | SDKROOT = iphoneos; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Release; 283 | }; 284 | 201FD7741B62502100963F08 /* Debug */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | INFOPLIST_FILE = CustomViewSample/Info.plist; 289 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 290 | PRODUCT_NAME = "$(TARGET_NAME)"; 291 | SWIFT_VERSION = 3.0; 292 | }; 293 | name = Debug; 294 | }; 295 | 201FD7751B62502100963F08 /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | INFOPLIST_FILE = CustomViewSample/Info.plist; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 301 | PRODUCT_NAME = "$(TARGET_NAME)"; 302 | SWIFT_VERSION = 3.0; 303 | }; 304 | name = Release; 305 | }; 306 | /* End XCBuildConfiguration section */ 307 | 308 | /* Begin XCConfigurationList section */ 309 | 201FD74F1B62502000963F08 /* Build configuration list for PBXProject "CustomViewSample" */ = { 310 | isa = XCConfigurationList; 311 | buildConfigurations = ( 312 | 201FD7711B62502100963F08 /* Debug */, 313 | 201FD7721B62502100963F08 /* Release */, 314 | ); 315 | defaultConfigurationIsVisible = 0; 316 | defaultConfigurationName = Release; 317 | }; 318 | 201FD7731B62502100963F08 /* Build configuration list for PBXNativeTarget "CustomViewSample" */ = { 319 | isa = XCConfigurationList; 320 | buildConfigurations = ( 321 | 201FD7741B62502100963F08 /* Debug */, 322 | 201FD7751B62502100963F08 /* Release */, 323 | ); 324 | defaultConfigurationIsVisible = 0; 325 | defaultConfigurationName = Release; 326 | }; 327 | /* End XCConfigurationList section */ 328 | }; 329 | rootObject = 201FD74C1B62502000963F08 /* Project object */; 330 | } 331 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/project.xcworkspace/xcshareddata/CustomViewSample.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | E93FD6AB-49AB-4A03-9396-7C3C5F90867A 9 | IDESourceControlProjectName 10 | CustomViewSample 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | FCF9F5FA5B13368E3F0C74CEBDE1DDB8C2E86CEE 14 | https://github.com/himaratsu/CustomViewSample.git 15 | 16 | IDESourceControlProjectPath 17 | CustomViewSample.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | FCF9F5FA5B13368E3F0C74CEBDE1DDB8C2E86CEE 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/himaratsu/CustomViewSample.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | FCF9F5FA5B13368E3F0C74CEBDE1DDB8C2E86CEE 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | FCF9F5FA5B13368E3F0C74CEBDE1DDB8C2E86CEE 36 | IDESourceControlWCCName 37 | CustomViewSample 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/xcuserdata/himara2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/xcuserdata/himara2.xcuserdatad/xcschemes/CustomViewSample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/xcuserdata/himara2.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CustomViewSample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 201FD7531B62502000963F08 16 | 17 | primary 18 | 19 | 20 | 201FD7681B62502100963F08 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/xcuserdata/rhiramat.xcuserdatad/xcschemes/CustomViewSample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CustomViewSample.xcodeproj/xcuserdata/rhiramat.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CustomViewSample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 201FD7531B62502000963F08 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CustomViewSample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CustomViewSample 4 | // 5 | // Created by himara2 on 2015/07/24. 6 | // Copyright (c) 2015年 himara2. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /CustomViewSample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CustomViewSample/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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CustomViewSample/Images.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 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /CustomViewSample/Images.xcassets/alpaca_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "alpaca_icon.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CustomViewSample/Images.xcassets/alpaca_icon.imageset/alpaca_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/himaratsu/CustomViewSample/bf8c458590ed797c2ed804a424d8d3e5a712bd01/CustomViewSample/Images.xcassets/alpaca_icon.imageset/alpaca_icon.png -------------------------------------------------------------------------------- /CustomViewSample/Images.xcassets/profile_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "profile_icon.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CustomViewSample/Images.xcassets/profile_icon.imageset/profile_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/himaratsu/CustomViewSample/bf8c458590ed797c2ed804a424d8d3e5a712bd01/CustomViewSample/Images.xcassets/profile_icon.imageset/profile_icon.png -------------------------------------------------------------------------------- /CustomViewSample/Images.xcassets/startbutton_bg.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "startbutton_bg@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CustomViewSample/Images.xcassets/startbutton_bg.imageset/startbutton_bg@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/himaratsu/CustomViewSample/bf8c458590ed797c2ed804a424d8d3e5a712bd01/CustomViewSample/Images.xcassets/startbutton_bg.imageset/startbutton_bg@2x.png -------------------------------------------------------------------------------- /CustomViewSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | in.mashroom.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /CustomViewSample/MyCustomView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyCustomView.swift 3 | // CustomViewSample 4 | // 5 | // Created by himara2 on 2015/07/24. 6 | // Copyright (c) 2015年 himara2. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @IBDesignable 12 | class MyCustomView: UIView, XibInstantiatable { 13 | 14 | @IBOutlet weak var iconImageView: UIImageView! 15 | @IBOutlet weak var titleLabel: UILabel! 16 | @IBOutlet weak var okButton: UIButton! 17 | 18 | 19 | @IBInspectable var borderColor: UIColor = .clear { 20 | didSet { 21 | self.layer.borderColor = borderColor.cgColor 22 | } 23 | } 24 | 25 | @IBInspectable var borderWidth: CGFloat = 0 { 26 | didSet { 27 | self.layer.borderWidth = borderWidth 28 | } 29 | } 30 | 31 | @IBInspectable var cornerRadius: CGFloat = 0 { 32 | didSet { 33 | self.layer.cornerRadius = cornerRadius 34 | self.layer.masksToBounds = true 35 | } 36 | } 37 | 38 | @IBInspectable var titleText: String = "" { 39 | didSet { 40 | titleLabel.text = titleText 41 | } 42 | } 43 | 44 | @IBInspectable var iconImage: UIImage? { 45 | didSet { 46 | iconImageView.image = iconImage 47 | } 48 | } 49 | 50 | @IBInspectable var buttonTitle: String = "" { 51 | didSet { 52 | okButton.setTitle(buttonTitle, for: [.normal, .highlighted, .selected]) 53 | } 54 | } 55 | 56 | override init(frame: CGRect) { 57 | super.init(frame: frame) 58 | instantiate() 59 | } 60 | 61 | required init?(coder aDecoder: NSCoder) { 62 | super.init(coder: aDecoder) 63 | instantiate() 64 | } 65 | 66 | fileprivate func comminInit() { 67 | instantiate() 68 | } 69 | 70 | @IBAction func okButtonTouched(_ sender: AnyObject) { 71 | let appStoreUrl = "https://itunes.apple.com/app/id934444072?mt=8" 72 | if let URL = URL(string: appStoreUrl) { 73 | if UIApplication.shared.canOpenURL(URL) { 74 | UIApplication.shared.openURL(URL) 75 | } 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /CustomViewSample/MyCustomView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /CustomViewSample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CustomViewSample 4 | // 5 | // Created by himara2 on 2015/07/24. 6 | // Copyright (c) 2015年 himara2. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var customView: MyCustomView! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // use from code 19 | let customView = MyCustomView(frame: CGRect(x: 50, y: 100, width: 270, height: 200)) 20 | customView.titleLabel.text = "Hello!" 21 | view.addSubview(customView) 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /CustomViewSample/XibInstantiatable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XibInstantiatable.swift 3 | // CustomViewSample 4 | // 5 | // Created by 平松 亮介 on 2016/10/27. 6 | // Copyright © 2016年 himara2. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol XibInstantiatable { 12 | func instantiate() 13 | } 14 | 15 | extension XibInstantiatable where Self: UIView { 16 | func instantiate() { 17 | let bundle = Bundle(for: type(of: self)) 18 | let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle) 19 | guard let view = nib.instantiate(withOwner: self, options: nil).first as? UIView else { 20 | return 21 | } 22 | addSubview(view) 23 | 24 | view.translatesAutoresizingMaskIntoConstraints = false 25 | 26 | let bindings = ["view": view] 27 | addConstraints(NSLayoutConstraint.constraints( 28 | withVisualFormat: "H:|[view]|", 29 | options:NSLayoutFormatOptions(rawValue: 0), 30 | metrics:nil, 31 | views: bindings)) 32 | addConstraints(NSLayoutConstraint.constraints( 33 | withVisualFormat: "V:|[view]|", 34 | options:NSLayoutFormatOptions(rawValue: 0), 35 | metrics:nil, 36 | views: bindings)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomViewSample 2 | 3 | Howt to create Custom UIView can be initialized from Nib file 4 | 5 | ## Usage 6 | 7 | ### Storyboard or xib 8 | 9 | implement @IBDesignable and @IBInspectable 10 | 11 | ![](http://cdn-ak.f.st-hatena.com/images/fotolife/h/himaratsu/20150726/20150726001117.gif) 12 | 13 | ![](http://cdn-ak.f.st-hatena.com/images/fotolife/h/himaratsu/20150726/20150726001213.gif) 14 | 15 | ### Code 16 | 17 | ```swift 18 | let customView = MyCustomView(frame: CGRectMake(50, 200, 280, 200)) 19 | view.addSubview(customView) 20 | ``` 21 | 22 | # More Info 23 | 24 | All step to create Custom view is written in http://himaratsu.hatenablog.com/entry/ios/customview . 25 | --------------------------------------------------------------------------------