├── .gitignore ├── AngleGradient ├── AngleGradientLayer.h └── AngleGradientLayer.m ├── AngleGradientLayer.podspec ├── AngleGradientSample ├── AngleGradientSample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── AngleGradientSample.xcscheme ├── AngleGradientSample │ ├── AngleGradientSample-Info.plist │ ├── AngleGradientSample-Prefix.pch │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── SampleController.h │ ├── SampleController.m │ ├── UserControl1.h │ ├── UserControl1.m │ ├── UserControl2.h │ ├── UserControl2.m │ ├── UserControl3.h │ ├── UserControl3.m │ ├── UserControl4.h │ ├── UserControl4.m │ ├── UserControl5.h │ ├── UserControl5.m │ ├── UserControl6.h │ ├── UserControl6.m │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m ├── AngleGradientSampleTests │ ├── AngleGradientSampleTests.m │ └── Info.plist ├── Default-568h@2x.png └── Podfile ├── ConicSample ├── ConicSample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── paiv.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── paiv.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── ConicSample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Gradients │ │ ├── UserGradient1.swift │ │ ├── UserGradient2.swift │ │ ├── UserGradient3.swift │ │ ├── UserGradient4.swift │ │ ├── UserGradient5.swift │ │ └── UserGradient6.swift │ ├── Info.plist │ └── SampleViewController.swift ├── readme.md └── screenshot.png ├── LICENSE ├── README.md └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | Podfile.lock 2 | Pods 3 | -------------------------------------------------------------------------------- /AngleGradient/AngleGradientLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // The MIT License (MIT) 3 | // 4 | // Copyright (C) 2012 Pavel Ivashkov 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | // and associated documentation files (the "Software"), to deal in the Software without restriction, 8 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all copies or 13 | // substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 18 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | // 22 | // 23 | // AngleGradientLayer.h 24 | // paiv 25 | // 26 | // Created by Pavel Ivashkov on 2012-02-12. 27 | // 28 | 29 | #import 30 | 31 | 32 | @interface AngleGradientLayer : CALayer 33 | 34 | /* The array of CGColorRef objects defining the color of each gradient 35 | * stop. Defaults to nil. */ 36 | 37 | @property(copy) NSArray *colors; 38 | 39 | /* An optional array of NSNumber objects defining the location of each 40 | * gradient stop as a value in the range [0,1]. The values must be 41 | * monotonically increasing. If a nil array is given, the stops are 42 | * assumed to spread uniformly across the [0,1] range. When rendered, 43 | * the colors are mapped to the output colorspace before being 44 | * interpolated. Defaults to nil. */ 45 | 46 | @property(copy) NSArray *locations; 47 | 48 | //Start angle. Default is 0. 49 | 50 | @property (nonatomic) CGFloat startAngle; 51 | 52 | /* The core method generating gradient image. 53 | */ 54 | + (CGImageRef)newImageGradientInRect:(CGRect)rect colors:(NSArray *)colors locations:(NSArray *)locations; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /AngleGradient/AngleGradientLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // The MIT License (MIT) 3 | // 4 | // Copyright (C) 2012 Pavel Ivashkov 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this 7 | // software and associated documentation files (the "Software"), to deal in the Software 8 | // without restriction, including without limitation the rights to use, copy, modify, merge, 9 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 10 | // to whom the Software is furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all copies or 13 | // substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 | // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 18 | // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | // DEALINGS IN THE SOFTWARE. 21 | // 22 | // 23 | // AngleGradientLayer.m 24 | // paiv 25 | // 26 | // Created by Pavel Ivashkov on 2012-02-12. 27 | // 28 | 29 | #import "AngleGradientLayer.h" 30 | 31 | #if __has_feature(objc_arc) 32 | #define BRIDGE_CAST(T) (__bridge T) 33 | #else 34 | #define BRIDGE_CAST(T) (T) 35 | #endif 36 | 37 | #define byte unsigned char 38 | #define F2CC(x) ((byte)(255 * x)) 39 | #define RGBAF(r,g,b,a) (F2CC(r) << 24 | F2CC(g) << 16 | F2CC(b) << 8 | F2CC(a)) 40 | #define RGBA(r,g,b,a) ((byte)r << 24 | (byte)g << 16 | (byte)b << 8 | (byte)a) 41 | #define RGBA_R(c) ((uint)c >> 24 & 255) 42 | #define RGBA_G(c) ((uint)c >> 16 & 255) 43 | #define RGBA_B(c) ((uint)c >> 8 & 255) 44 | #define RGBA_A(c) ((uint)c >> 0 & 255) 45 | 46 | @interface AngleGradientLayer() 47 | 48 | - (CGImageRef)newImageGradientInRect:(CGRect)rect; 49 | 50 | @end 51 | 52 | 53 | static void angleGradient(byte* data, int w, int h, int* colors, int colorCount, float* locations, int locationCount); 54 | 55 | 56 | @implementation AngleGradientLayer 57 | 58 | - (id)init 59 | { 60 | if (!(self = [super init])) 61 | return nil; 62 | 63 | self.needsDisplayOnBoundsChange = YES; 64 | 65 | return self; 66 | } 67 | 68 | #if !__has_feature(objc_arc) 69 | - (void)dealloc 70 | { 71 | [_colors release]; 72 | [_locations release]; 73 | [super dealloc]; 74 | } 75 | #endif 76 | 77 | - (void)drawInContext:(CGContextRef)ctx 78 | { 79 | CGContextSetFillColorWithColor(ctx, self.backgroundColor); 80 | CGContextRotateCTM(ctx, self.startAngle); 81 | CGRect rect = CGContextGetClipBoundingBox(ctx); 82 | CGContextFillRect(ctx, rect); 83 | 84 | CGImageRef img = [self newImageGradientInRect:rect]; 85 | CGContextDrawImage(ctx, rect, img); 86 | CGImageRelease(img); 87 | } 88 | 89 | - (CGImageRef)newImageGradientInRect:(CGRect)rect 90 | { 91 | return [[self class] newImageGradientInRect:rect colors:self.colors locations:self.locations]; 92 | } 93 | 94 | + (CGImageRef)newImageGradientInRect:(CGRect)rect colors:(NSArray *)colors locations:(NSArray *)locations 95 | { 96 | int w = CGRectGetWidth(rect); 97 | int h = CGRectGetHeight(rect); 98 | int bitsPerComponent = 8; 99 | int bpp = 4 * bitsPerComponent / 8; 100 | int byteCount = w * h * bpp; 101 | 102 | int colorCount = (int)colors.count; 103 | int locationCount = (int)locations.count; 104 | int* cols = NULL; 105 | float* locs = NULL; 106 | 107 | if (colorCount > 0) { 108 | cols = calloc(colorCount, bpp); 109 | int *p = cols; 110 | for (id cg in colors) { 111 | CGColorRef c = BRIDGE_CAST(CGColorRef)cg; 112 | float r, g, b, a; 113 | 114 | size_t n = CGColorGetNumberOfComponents(c); 115 | const CGFloat *comps = CGColorGetComponents(c); 116 | if (comps == NULL) { 117 | *p++ = 0; 118 | continue; 119 | } 120 | r = comps[0]; 121 | if (n >= 4) { 122 | g = comps[1]; 123 | b = comps[2]; 124 | a = comps[3]; 125 | } 126 | else { 127 | g = b = r; 128 | a = comps[1]; 129 | } 130 | *p++ = RGBAF(r, g, b, a); 131 | } 132 | } 133 | if (locationCount > 0 && locationCount == colorCount) { 134 | locs = calloc(locationCount, sizeof(locs[0])); 135 | float *p = locs; 136 | for (NSNumber *n in locations) { 137 | *p++ = [n floatValue]; 138 | } 139 | } 140 | 141 | byte* data = malloc(byteCount); 142 | angleGradient(data, w, h, cols, colorCount, locs, locationCount); 143 | 144 | if (cols) free(cols); 145 | if (locs) free(locs); 146 | 147 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 148 | CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Little; 149 | CGContextRef ctx = CGBitmapContextCreate(data, w, h, bitsPerComponent, w * bpp, colorSpace, bitmapInfo); 150 | CGColorSpaceRelease(colorSpace); 151 | CGImageRef img = CGBitmapContextCreateImage(ctx); 152 | CGContextRelease(ctx); 153 | free(data); 154 | return img; 155 | } 156 | 157 | @end 158 | 159 | static inline byte blerp(byte a, byte b, float w) 160 | { 161 | return a + w * (b - a); 162 | } 163 | static inline int lerp(int a, int b, float w) 164 | { 165 | return RGBA(blerp(RGBA_R(a), RGBA_R(b), w), 166 | blerp(RGBA_G(a), RGBA_G(b), w), 167 | blerp(RGBA_B(a), RGBA_B(b), w), 168 | blerp(RGBA_A(a), RGBA_A(b), w)); 169 | } 170 | static inline int multiplyByAlpha(int c) 171 | { 172 | float a = RGBA_A(c) / 255.0; 173 | return RGBA((byte)(RGBA_R(c) * a), 174 | (byte)(RGBA_G(c) * a), 175 | (byte)(RGBA_B(c) * a), 176 | RGBA_A(c)); 177 | } 178 | 179 | void angleGradient(byte* data, int w, int h, int* colors, int colorCount, float* locations, int locationCount) 180 | { 181 | if (colorCount < 1) return; 182 | if (locationCount > 0 && locationCount != colorCount) return; 183 | 184 | int* p = (int*)data; 185 | float centerX = (float)w / 2; 186 | float centerY = (float)h / 2; 187 | 188 | for (int y = 0; y < h; y++) 189 | for (int x = 0; x < w; x++) { 190 | float dirX = x - centerX; 191 | float dirY = y - centerY; 192 | float angle = atan2f(dirY, dirX); 193 | if (dirY < 0) angle += 2 * M_PI; 194 | angle /= 2 * M_PI; 195 | 196 | int index = 0, nextIndex = 0; 197 | float t = 0; 198 | 199 | if (locationCount > 0) { 200 | for (index = locationCount - 1; index >= 0; index--) { 201 | if (angle >= locations[index]) { 202 | break; 203 | } 204 | } 205 | if (index >= locationCount) index = locationCount - 1; 206 | nextIndex = index + 1; 207 | if (nextIndex >= locationCount) nextIndex = locationCount - 1; 208 | float ld = locations[nextIndex] - locations[index]; 209 | t = ld <= 0 ? 0 : (angle - locations[index]) / ld; 210 | } 211 | else { 212 | t = angle * (colorCount - 1); 213 | index = t; 214 | t -= index; 215 | nextIndex = index + 1; 216 | if (nextIndex >= colorCount) nextIndex = colorCount - 1; 217 | } 218 | 219 | int lc = colors[index]; 220 | int rc = colors[nextIndex]; 221 | int color = lerp(lc, rc, t); 222 | color = multiplyByAlpha(color); 223 | *p++ = color; 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /AngleGradientLayer.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'AngleGradientLayer' 3 | s.version = '1.2.3' 4 | s.summary = 'Objective-C angle gradients for iOS.' 5 | s.homepage = 'https://github.com/paiv/AngleGradientLayer' 6 | s.screenshots = 'https://raw.github.com/paiv/AngleGradientLayer/master/screenshot.png' 7 | s.license = 'MIT' 8 | s.author = 'Pavel Ivashkov' 9 | s.source = { :git => 'https://github.com/paiv/AngleGradientLayer.git', :tag => "v#{s.version}" } 10 | s.ios.deployment_target = '3.2' 11 | s.tvos.deployment_target = '9.0' 12 | s.source_files = 'AngleGradient/*.{h,m}' 13 | s.frameworks = 'CoreGraphics', 'QuartzCore' 14 | end 15 | 16 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 003B99E8A8DA00D2889AEC0B /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F84AA0F39DD9B225DCB04EB0 /* libPods.a */; }; 11 | C40F40D614E71A7B00566C8F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40D514E71A7B00566C8F /* UIKit.framework */; }; 12 | C40F40D814E71A7B00566C8F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40D714E71A7B00566C8F /* Foundation.framework */; }; 13 | C40F40DA14E71A7B00566C8F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40D914E71A7B00566C8F /* CoreGraphics.framework */; }; 14 | C40F40E014E71A7B00566C8F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C40F40DE14E71A7B00566C8F /* InfoPlist.strings */; }; 15 | C40F40E214E71A7B00566C8F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40E114E71A7B00566C8F /* main.m */; }; 16 | C40F40E614E71A7B00566C8F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40E514E71A7B00566C8F /* AppDelegate.m */; }; 17 | C40F40F314E71B3800566C8F /* SampleController.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40F214E71B3800566C8F /* SampleController.m */; }; 18 | C40F40F514E71C1600566C8F /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C40F40F414E71C1600566C8F /* QuartzCore.framework */; }; 19 | C40F40F814E71D0700566C8F /* UserControl1.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F40F714E71D0700566C8F /* UserControl1.m */; }; 20 | C40F410214E75C9A00566C8F /* UserControl2.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410114E75C9900566C8F /* UserControl2.m */; }; 21 | C40F410514E761FD00566C8F /* UserControl3.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410414E761FD00566C8F /* UserControl3.m */; }; 22 | C40F410814E7663100566C8F /* UserControl4.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410714E7663100566C8F /* UserControl4.m */; }; 23 | C40F410C14E7693400566C8F /* UserControl5.m in Sources */ = {isa = PBXBuildFile; fileRef = C40F410B14E7693400566C8F /* UserControl5.m */; }; 24 | C42DE8FE1762632700006619 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C42DE8FD1762632700006619 /* Default-568h@2x.png */; }; 25 | C45ACB1D1B41DE8800D71D7C /* AngleGradientSampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C45ACB1C1B41DE8800D71D7C /* AngleGradientSampleTests.m */; }; 26 | C49C2FB314E7E9D200E36420 /* UserControl6.m in Sources */ = {isa = PBXBuildFile; fileRef = C49C2FB214E7E9D200E36420 /* UserControl6.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | C45ACB231B41DEEC00D71D7C /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = C40F40C814E71A7A00566C8F /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = C40F40D014E71A7A00566C8F; 35 | remoteInfo = AngleGradientSample; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 76D72F111AD2A8EBE12C428E /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 41 | 7F8273EDAA850DF02B07BEC9 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 42 | C40F40D114E71A7B00566C8F /* AngleGradientSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AngleGradientSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | C40F40D514E71A7B00566C8F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 44 | C40F40D714E71A7B00566C8F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 45 | C40F40D914E71A7B00566C8F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 46 | C40F40DD14E71A7B00566C8F /* AngleGradientSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AngleGradientSample-Info.plist"; sourceTree = ""; }; 47 | C40F40DF14E71A7B00566C8F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 48 | C40F40E114E71A7B00566C8F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49 | C40F40E314E71A7B00566C8F /* AngleGradientSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AngleGradientSample-Prefix.pch"; sourceTree = ""; }; 50 | C40F40E414E71A7B00566C8F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 51 | C40F40E514E71A7B00566C8F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 52 | C40F40F114E71B3800566C8F /* SampleController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SampleController.h; sourceTree = ""; }; 53 | C40F40F214E71B3800566C8F /* SampleController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SampleController.m; sourceTree = ""; }; 54 | C40F40F414E71C1600566C8F /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 55 | C40F40F614E71D0700566C8F /* UserControl1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl1.h; sourceTree = ""; }; 56 | C40F40F714E71D0700566C8F /* UserControl1.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl1.m; sourceTree = ""; }; 57 | C40F410014E75C9900566C8F /* UserControl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl2.h; sourceTree = ""; }; 58 | C40F410114E75C9900566C8F /* UserControl2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl2.m; sourceTree = ""; }; 59 | C40F410314E761FD00566C8F /* UserControl3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl3.h; sourceTree = ""; }; 60 | C40F410414E761FD00566C8F /* UserControl3.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl3.m; sourceTree = ""; }; 61 | C40F410614E7663100566C8F /* UserControl4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl4.h; sourceTree = ""; }; 62 | C40F410714E7663100566C8F /* UserControl4.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl4.m; sourceTree = ""; }; 63 | C40F410A14E7693400566C8F /* UserControl5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl5.h; sourceTree = ""; }; 64 | C40F410B14E7693400566C8F /* UserControl5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl5.m; sourceTree = ""; }; 65 | C42DE8FD1762632700006619 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = ""; }; 66 | C45ACB181B41DE8700D71D7C /* AngleGradientSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AngleGradientSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 67 | C45ACB1B1B41DE8800D71D7C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 68 | C45ACB1C1B41DE8800D71D7C /* AngleGradientSampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AngleGradientSampleTests.m; sourceTree = ""; }; 69 | C49C2FB114E7E9D200E36420 /* UserControl6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserControl6.h; sourceTree = ""; }; 70 | C49C2FB214E7E9D200E36420 /* UserControl6.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserControl6.m; sourceTree = ""; }; 71 | F84AA0F39DD9B225DCB04EB0 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | /* End PBXFileReference section */ 73 | 74 | /* Begin PBXFrameworksBuildPhase section */ 75 | C40F40CE14E71A7A00566C8F /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | C40F40D614E71A7B00566C8F /* UIKit.framework in Frameworks */, 80 | C40F40D814E71A7B00566C8F /* Foundation.framework in Frameworks */, 81 | C40F40DA14E71A7B00566C8F /* CoreGraphics.framework in Frameworks */, 82 | C40F40F514E71C1600566C8F /* QuartzCore.framework in Frameworks */, 83 | 003B99E8A8DA00D2889AEC0B /* libPods.a in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | C45ACB151B41DE8700D71D7C /* Frameworks */ = { 88 | isa = PBXFrameworksBuildPhase; 89 | buildActionMask = 2147483647; 90 | files = ( 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | /* End PBXFrameworksBuildPhase section */ 95 | 96 | /* Begin PBXGroup section */ 97 | 4616A104C572A3B0EABE6C5B /* Pods */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 7F8273EDAA850DF02B07BEC9 /* Pods.debug.xcconfig */, 101 | 76D72F111AD2A8EBE12C428E /* Pods.release.xcconfig */, 102 | ); 103 | name = Pods; 104 | sourceTree = ""; 105 | }; 106 | C40F40C614E71A7A00566C8F = { 107 | isa = PBXGroup; 108 | children = ( 109 | C40F40DB14E71A7B00566C8F /* AngleGradientSample */, 110 | C45ACB191B41DE8800D71D7C /* AngleGradientSampleTests */, 111 | C40F40D414E71A7B00566C8F /* Frameworks */, 112 | C40F40D214E71A7B00566C8F /* Products */, 113 | 4616A104C572A3B0EABE6C5B /* Pods */, 114 | ); 115 | sourceTree = ""; 116 | }; 117 | C40F40D214E71A7B00566C8F /* Products */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | C40F40D114E71A7B00566C8F /* AngleGradientSample.app */, 121 | C45ACB181B41DE8700D71D7C /* AngleGradientSampleTests.xctest */, 122 | ); 123 | name = Products; 124 | sourceTree = ""; 125 | }; 126 | C40F40D414E71A7B00566C8F /* Frameworks */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | C40F40D514E71A7B00566C8F /* UIKit.framework */, 130 | C40F40D714E71A7B00566C8F /* Foundation.framework */, 131 | C40F40D914E71A7B00566C8F /* CoreGraphics.framework */, 132 | C40F40F414E71C1600566C8F /* QuartzCore.framework */, 133 | F84AA0F39DD9B225DCB04EB0 /* libPods.a */, 134 | ); 135 | name = Frameworks; 136 | sourceTree = ""; 137 | }; 138 | C40F40DB14E71A7B00566C8F /* AngleGradientSample */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | C40F40E414E71A7B00566C8F /* AppDelegate.h */, 142 | C40F40E514E71A7B00566C8F /* AppDelegate.m */, 143 | C40F40F114E71B3800566C8F /* SampleController.h */, 144 | C40F40F214E71B3800566C8F /* SampleController.m */, 145 | C40F410914E766F300566C8F /* Samples */, 146 | C40F40DC14E71A7B00566C8F /* Supporting Files */, 147 | ); 148 | path = AngleGradientSample; 149 | sourceTree = ""; 150 | }; 151 | C40F40DC14E71A7B00566C8F /* Supporting Files */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | C40F40DD14E71A7B00566C8F /* AngleGradientSample-Info.plist */, 155 | C40F40DE14E71A7B00566C8F /* InfoPlist.strings */, 156 | C40F40E114E71A7B00566C8F /* main.m */, 157 | C40F40E314E71A7B00566C8F /* AngleGradientSample-Prefix.pch */, 158 | C42DE8FD1762632700006619 /* Default-568h@2x.png */, 159 | ); 160 | name = "Supporting Files"; 161 | sourceTree = ""; 162 | }; 163 | C40F410914E766F300566C8F /* Samples */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | C40F40F614E71D0700566C8F /* UserControl1.h */, 167 | C40F40F714E71D0700566C8F /* UserControl1.m */, 168 | C40F410014E75C9900566C8F /* UserControl2.h */, 169 | C40F410114E75C9900566C8F /* UserControl2.m */, 170 | C40F410314E761FD00566C8F /* UserControl3.h */, 171 | C40F410414E761FD00566C8F /* UserControl3.m */, 172 | C40F410614E7663100566C8F /* UserControl4.h */, 173 | C40F410714E7663100566C8F /* UserControl4.m */, 174 | C40F410A14E7693400566C8F /* UserControl5.h */, 175 | C40F410B14E7693400566C8F /* UserControl5.m */, 176 | C49C2FB114E7E9D200E36420 /* UserControl6.h */, 177 | C49C2FB214E7E9D200E36420 /* UserControl6.m */, 178 | ); 179 | name = Samples; 180 | sourceTree = ""; 181 | }; 182 | C45ACB191B41DE8800D71D7C /* AngleGradientSampleTests */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | C45ACB1C1B41DE8800D71D7C /* AngleGradientSampleTests.m */, 186 | C45ACB1A1B41DE8800D71D7C /* Supporting Files */, 187 | ); 188 | path = AngleGradientSampleTests; 189 | sourceTree = ""; 190 | }; 191 | C45ACB1A1B41DE8800D71D7C /* Supporting Files */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | C45ACB1B1B41DE8800D71D7C /* Info.plist */, 195 | ); 196 | name = "Supporting Files"; 197 | sourceTree = ""; 198 | }; 199 | /* End PBXGroup section */ 200 | 201 | /* Begin PBXNativeTarget section */ 202 | C40F40D014E71A7A00566C8F /* AngleGradientSample */ = { 203 | isa = PBXNativeTarget; 204 | buildConfigurationList = C40F40E914E71A7B00566C8F /* Build configuration list for PBXNativeTarget "AngleGradientSample" */; 205 | buildPhases = ( 206 | E0CB3F1B846FA6B80459F9CC /* Check Pods Manifest.lock */, 207 | C40F40CD14E71A7A00566C8F /* Sources */, 208 | C40F40CE14E71A7A00566C8F /* Frameworks */, 209 | C40F40CF14E71A7A00566C8F /* Resources */, 210 | B94F94CF150089EB86C905CC /* Copy Pods Resources */, 211 | ); 212 | buildRules = ( 213 | ); 214 | dependencies = ( 215 | ); 216 | name = AngleGradientSample; 217 | productName = AngleGradientSample; 218 | productReference = C40F40D114E71A7B00566C8F /* AngleGradientSample.app */; 219 | productType = "com.apple.product-type.application"; 220 | }; 221 | C45ACB171B41DE8700D71D7C /* AngleGradientSampleTests */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = C45ACB221B41DE8800D71D7C /* Build configuration list for PBXNativeTarget "AngleGradientSampleTests" */; 224 | buildPhases = ( 225 | C45ACB141B41DE8700D71D7C /* Sources */, 226 | C45ACB151B41DE8700D71D7C /* Frameworks */, 227 | C45ACB161B41DE8700D71D7C /* Resources */, 228 | ); 229 | buildRules = ( 230 | ); 231 | dependencies = ( 232 | C45ACB241B41DEEC00D71D7C /* PBXTargetDependency */, 233 | ); 234 | name = AngleGradientSampleTests; 235 | productName = AngleGradientSampleTests; 236 | productReference = C45ACB181B41DE8700D71D7C /* AngleGradientSampleTests.xctest */; 237 | productType = "com.apple.product-type.bundle.unit-test"; 238 | }; 239 | /* End PBXNativeTarget section */ 240 | 241 | /* Begin PBXProject section */ 242 | C40F40C814E71A7A00566C8F /* Project object */ = { 243 | isa = PBXProject; 244 | attributes = { 245 | LastUpgradeCheck = 0640; 246 | ORGANIZATIONNAME = paiv; 247 | TargetAttributes = { 248 | C45ACB171B41DE8700D71D7C = { 249 | CreatedOnToolsVersion = 6.3.2; 250 | TestTargetID = C40F40D014E71A7A00566C8F; 251 | }; 252 | }; 253 | }; 254 | buildConfigurationList = C40F40CB14E71A7A00566C8F /* Build configuration list for PBXProject "AngleGradientSample" */; 255 | compatibilityVersion = "Xcode 3.2"; 256 | developmentRegion = English; 257 | hasScannedForEncodings = 0; 258 | knownRegions = ( 259 | en, 260 | ); 261 | mainGroup = C40F40C614E71A7A00566C8F; 262 | productRefGroup = C40F40D214E71A7B00566C8F /* Products */; 263 | projectDirPath = ""; 264 | projectRoot = ""; 265 | targets = ( 266 | C40F40D014E71A7A00566C8F /* AngleGradientSample */, 267 | C45ACB171B41DE8700D71D7C /* AngleGradientSampleTests */, 268 | ); 269 | }; 270 | /* End PBXProject section */ 271 | 272 | /* Begin PBXResourcesBuildPhase section */ 273 | C40F40CF14E71A7A00566C8F /* Resources */ = { 274 | isa = PBXResourcesBuildPhase; 275 | buildActionMask = 2147483647; 276 | files = ( 277 | C40F40E014E71A7B00566C8F /* InfoPlist.strings in Resources */, 278 | C42DE8FE1762632700006619 /* Default-568h@2x.png in Resources */, 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | C45ACB161B41DE8700D71D7C /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | /* End PBXResourcesBuildPhase section */ 290 | 291 | /* Begin PBXShellScriptBuildPhase section */ 292 | B94F94CF150089EB86C905CC /* Copy Pods Resources */ = { 293 | isa = PBXShellScriptBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | ); 297 | inputPaths = ( 298 | ); 299 | name = "Copy Pods Resources"; 300 | outputPaths = ( 301 | ); 302 | runOnlyForDeploymentPostprocessing = 0; 303 | shellPath = /bin/sh; 304 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; 305 | showEnvVarsInLog = 0; 306 | }; 307 | E0CB3F1B846FA6B80459F9CC /* Check Pods Manifest.lock */ = { 308 | isa = PBXShellScriptBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | ); 312 | inputPaths = ( 313 | ); 314 | name = "Check Pods Manifest.lock"; 315 | outputPaths = ( 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | shellPath = /bin/sh; 319 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 320 | showEnvVarsInLog = 0; 321 | }; 322 | /* End PBXShellScriptBuildPhase section */ 323 | 324 | /* Begin PBXSourcesBuildPhase section */ 325 | C40F40CD14E71A7A00566C8F /* Sources */ = { 326 | isa = PBXSourcesBuildPhase; 327 | buildActionMask = 2147483647; 328 | files = ( 329 | C40F40E214E71A7B00566C8F /* main.m in Sources */, 330 | C40F40E614E71A7B00566C8F /* AppDelegate.m in Sources */, 331 | C40F40F314E71B3800566C8F /* SampleController.m in Sources */, 332 | C40F40F814E71D0700566C8F /* UserControl1.m in Sources */, 333 | C40F410214E75C9A00566C8F /* UserControl2.m in Sources */, 334 | C40F410514E761FD00566C8F /* UserControl3.m in Sources */, 335 | C40F410814E7663100566C8F /* UserControl4.m in Sources */, 336 | C40F410C14E7693400566C8F /* UserControl5.m in Sources */, 337 | C49C2FB314E7E9D200E36420 /* UserControl6.m in Sources */, 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | C45ACB141B41DE8700D71D7C /* Sources */ = { 342 | isa = PBXSourcesBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | C45ACB1D1B41DE8800D71D7C /* AngleGradientSampleTests.m in Sources */, 346 | ); 347 | runOnlyForDeploymentPostprocessing = 0; 348 | }; 349 | /* End PBXSourcesBuildPhase section */ 350 | 351 | /* Begin PBXTargetDependency section */ 352 | C45ACB241B41DEEC00D71D7C /* PBXTargetDependency */ = { 353 | isa = PBXTargetDependency; 354 | target = C40F40D014E71A7A00566C8F /* AngleGradientSample */; 355 | targetProxy = C45ACB231B41DEEC00D71D7C /* PBXContainerItemProxy */; 356 | }; 357 | /* End PBXTargetDependency section */ 358 | 359 | /* Begin PBXVariantGroup section */ 360 | C40F40DE14E71A7B00566C8F /* InfoPlist.strings */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | C40F40DF14E71A7B00566C8F /* en */, 364 | ); 365 | name = InfoPlist.strings; 366 | sourceTree = ""; 367 | }; 368 | /* End PBXVariantGroup section */ 369 | 370 | /* Begin XCBuildConfiguration section */ 371 | C40F40E714E71A7B00566C8F /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | CLANG_ENABLE_OBJC_ARC = YES; 376 | CLANG_WARN_BOOL_CONVERSION = YES; 377 | CLANG_WARN_CONSTANT_CONVERSION = YES; 378 | CLANG_WARN_EMPTY_BODY = YES; 379 | CLANG_WARN_ENUM_CONVERSION = YES; 380 | CLANG_WARN_INT_CONVERSION = YES; 381 | CLANG_WARN_UNREACHABLE_CODE = YES; 382 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 383 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 384 | COPY_PHASE_STRIP = NO; 385 | ENABLE_STRICT_OBJC_MSGSEND = YES; 386 | GCC_C_LANGUAGE_STANDARD = gnu99; 387 | GCC_DYNAMIC_NO_PIC = NO; 388 | GCC_NO_COMMON_BLOCKS = YES; 389 | GCC_OPTIMIZATION_LEVEL = 0; 390 | GCC_PREPROCESSOR_DEFINITIONS = ( 391 | "DEBUG=1", 392 | "$(inherited)", 393 | ); 394 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 395 | GCC_THUMB_SUPPORT = NO; 396 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 397 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 398 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 399 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 400 | GCC_WARN_UNDECLARED_SELECTOR = YES; 401 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 402 | GCC_WARN_UNUSED_FUNCTION = YES; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 405 | ONLY_ACTIVE_ARCH = YES; 406 | SDKROOT = iphoneos; 407 | }; 408 | name = Debug; 409 | }; 410 | C40F40E814E71A7B00566C8F /* Release */ = { 411 | isa = XCBuildConfiguration; 412 | buildSettings = { 413 | ALWAYS_SEARCH_USER_PATHS = NO; 414 | CLANG_ENABLE_OBJC_ARC = YES; 415 | CLANG_WARN_BOOL_CONVERSION = YES; 416 | CLANG_WARN_CONSTANT_CONVERSION = YES; 417 | CLANG_WARN_EMPTY_BODY = YES; 418 | CLANG_WARN_ENUM_CONVERSION = YES; 419 | CLANG_WARN_INT_CONVERSION = YES; 420 | CLANG_WARN_UNREACHABLE_CODE = YES; 421 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 422 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 423 | COPY_PHASE_STRIP = YES; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | GCC_C_LANGUAGE_STANDARD = gnu99; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_THUMB_SUPPORT = NO; 428 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 429 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 430 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 431 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 432 | GCC_WARN_UNDECLARED_SELECTOR = YES; 433 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 434 | GCC_WARN_UNUSED_FUNCTION = YES; 435 | GCC_WARN_UNUSED_VARIABLE = YES; 436 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 437 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 438 | SDKROOT = iphoneos; 439 | VALIDATE_PRODUCT = YES; 440 | }; 441 | name = Release; 442 | }; 443 | C40F40EA14E71A7B00566C8F /* Debug */ = { 444 | isa = XCBuildConfiguration; 445 | baseConfigurationReference = 7F8273EDAA850DF02B07BEC9 /* Pods.debug.xcconfig */; 446 | buildSettings = { 447 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 448 | GCC_PREFIX_HEADER = "AngleGradientSample/AngleGradientSample-Prefix.pch"; 449 | GCC_THUMB_SUPPORT = NO; 450 | INFOPLIST_FILE = "AngleGradientSample/AngleGradientSample-Info.plist"; 451 | PRODUCT_NAME = "$(TARGET_NAME)"; 452 | WRAPPER_EXTENSION = app; 453 | }; 454 | name = Debug; 455 | }; 456 | C40F40EB14E71A7B00566C8F /* Release */ = { 457 | isa = XCBuildConfiguration; 458 | baseConfigurationReference = 76D72F111AD2A8EBE12C428E /* Pods.release.xcconfig */; 459 | buildSettings = { 460 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 461 | GCC_PREFIX_HEADER = "AngleGradientSample/AngleGradientSample-Prefix.pch"; 462 | GCC_THUMB_SUPPORT = NO; 463 | INFOPLIST_FILE = "AngleGradientSample/AngleGradientSample-Info.plist"; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | WRAPPER_EXTENSION = app; 466 | }; 467 | name = Release; 468 | }; 469 | C45ACB201B41DE8800D71D7C /* Debug */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | BUNDLE_LOADER = "$(TEST_HOST)"; 473 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 474 | CLANG_CXX_LIBRARY = "libc++"; 475 | CLANG_ENABLE_MODULES = YES; 476 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 477 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 478 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 479 | FRAMEWORK_SEARCH_PATHS = ( 480 | "$(SDKROOT)/Developer/Library/Frameworks", 481 | "$(inherited)", 482 | ); 483 | GCC_PREPROCESSOR_DEFINITIONS = ( 484 | "DEBUG=1", 485 | "$(inherited)", 486 | ); 487 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 488 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 489 | INFOPLIST_FILE = AngleGradientSampleTests/Info.plist; 490 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 492 | MTL_ENABLE_DEBUG_INFO = YES; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AngleGradientSample.app/AngleGradientSample"; 495 | }; 496 | name = Debug; 497 | }; 498 | C45ACB211B41DE8800D71D7C /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | BUNDLE_LOADER = "$(TEST_HOST)"; 502 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 503 | CLANG_CXX_LIBRARY = "libc++"; 504 | CLANG_ENABLE_MODULES = YES; 505 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 506 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 507 | COPY_PHASE_STRIP = NO; 508 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 509 | ENABLE_NS_ASSERTIONS = NO; 510 | FRAMEWORK_SEARCH_PATHS = ( 511 | "$(SDKROOT)/Developer/Library/Frameworks", 512 | "$(inherited)", 513 | ); 514 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 515 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 516 | INFOPLIST_FILE = AngleGradientSampleTests/Info.plist; 517 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 519 | MTL_ENABLE_DEBUG_INFO = NO; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AngleGradientSample.app/AngleGradientSample"; 522 | }; 523 | name = Release; 524 | }; 525 | /* End XCBuildConfiguration section */ 526 | 527 | /* Begin XCConfigurationList section */ 528 | C40F40CB14E71A7A00566C8F /* Build configuration list for PBXProject "AngleGradientSample" */ = { 529 | isa = XCConfigurationList; 530 | buildConfigurations = ( 531 | C40F40E714E71A7B00566C8F /* Debug */, 532 | C40F40E814E71A7B00566C8F /* Release */, 533 | ); 534 | defaultConfigurationIsVisible = 0; 535 | defaultConfigurationName = Release; 536 | }; 537 | C40F40E914E71A7B00566C8F /* Build configuration list for PBXNativeTarget "AngleGradientSample" */ = { 538 | isa = XCConfigurationList; 539 | buildConfigurations = ( 540 | C40F40EA14E71A7B00566C8F /* Debug */, 541 | C40F40EB14E71A7B00566C8F /* Release */, 542 | ); 543 | defaultConfigurationIsVisible = 0; 544 | defaultConfigurationName = Release; 545 | }; 546 | C45ACB221B41DE8800D71D7C /* Build configuration list for PBXNativeTarget "AngleGradientSampleTests" */ = { 547 | isa = XCConfigurationList; 548 | buildConfigurations = ( 549 | C45ACB201B41DE8800D71D7C /* Debug */, 550 | C45ACB211B41DE8800D71D7C /* Release */, 551 | ); 552 | defaultConfigurationIsVisible = 0; 553 | }; 554 | /* End XCConfigurationList section */ 555 | }; 556 | rootObject = C40F40C814E71A7A00566C8F /* Project object */; 557 | } 558 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample.xcodeproj/xcshareddata/xcschemes/AngleGradientSample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 89 | 91 | 97 | 98 | 99 | 100 | 101 | 102 | 108 | 110 | 116 | 117 | 118 | 119 | 121 | 122 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/AngleGradientSample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | paiv.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/AngleGradientSample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'AngleGradientSample' target in the 'AngleGradientSample' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-11. 6 | // 7 | 8 | #import 9 | 10 | @interface AppDelegate : UIResponder 11 | 12 | @property (strong, nonatomic) UIWindow *window; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-11. 6 | // 7 | 8 | #import "AppDelegate.h" 9 | #import "SampleController.h" 10 | 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | // Override point for customization after application launch. 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | 20 | SampleController *vc = [[SampleController alloc] init]; 21 | [self.window setRootViewController:vc]; 22 | 23 | [self.window makeKeyAndVisible]; 24 | return YES; 25 | } 26 | 27 | - (void)applicationWillResignActive:(UIApplication *)application 28 | { 29 | /* 30 | 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. 31 | 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. 32 | */ 33 | } 34 | 35 | - (void)applicationDidEnterBackground:(UIApplication *)application 36 | { 37 | /* 38 | 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. 39 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | */ 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application 44 | { 45 | /* 46 | 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. 47 | */ 48 | } 49 | 50 | - (void)applicationDidBecomeActive:(UIApplication *)application 51 | { 52 | /* 53 | 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. 54 | */ 55 | } 56 | 57 | - (void)applicationWillTerminate:(UIApplication *)application 58 | { 59 | /* 60 | Called when the application is about to terminate. 61 | Save data if appropriate. 62 | See also applicationDidEnterBackground:. 63 | */ 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/SampleController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SampleController.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-11. 6 | // 7 | 8 | @interface SampleController : UIViewController 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/SampleController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SampleController.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-11. 6 | // 7 | 8 | #import 9 | #import "SampleController.h" 10 | #import "UserControl1.h" 11 | #import "UserControl2.h" 12 | #import "UserControl3.h" 13 | #import "UserControl4.h" 14 | #import "UserControl5.h" 15 | #import "UserControl6.h" 16 | 17 | 18 | @interface SampleController() 19 | 20 | @property(strong, nonatomic) UIControl *uc5; 21 | 22 | @end 23 | 24 | 25 | @implementation SampleController 26 | 27 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 28 | { 29 | if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) 30 | return nil; 31 | return self; 32 | } 33 | 34 | - (void)didReceiveMemoryWarning 35 | { 36 | // Releases the view if it doesn't have a superview. 37 | [super didReceiveMemoryWarning]; 38 | 39 | // Release any cached data, images, etc that aren't in use. 40 | } 41 | 42 | - (void)handleDragInside:(UIControl *)control withEvent:(UIEvent *)event 43 | { 44 | [control.superview bringSubviewToFront:control]; 45 | control.center = [[[event allTouches] anyObject] locationInView:control.superview]; 46 | } 47 | 48 | #pragma mark - View lifecycle 49 | 50 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 51 | - (void)loadView 52 | { 53 | CGRect rect = [UIScreen mainScreen].applicationFrame; 54 | UIScrollView *v = [[UIScrollView alloc] initWithFrame:rect]; 55 | v.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 56 | v.backgroundColor = [UIColor whiteColor]; 57 | 58 | UserControl1 *uc1 = [[UserControl1 alloc] initWithFrame:v.bounds]; 59 | uc1.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 60 | [v addSubview:uc1]; 61 | 62 | UIViewAutoresizing flexmargins = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 63 | 64 | UserControl2 *uc2 = [[UserControl2 alloc] initWithFrame:CGRectMake(5, 5, 88, 88)]; 65 | uc2.autoresizingMask = flexmargins; 66 | [v addSubview:uc2]; 67 | 68 | UserControl3 *uc3 = [[UserControl3 alloc] initWithFrame:CGRectMake(155, 95, 66, 66)]; 69 | [v addSubview:uc3]; 70 | 71 | UserControl4 *uc4 = [[UserControl4 alloc] initWithFrame:CGRectMake(190, 305, 120, 120)]; 72 | uc4.autoresizingMask = flexmargins; 73 | [v addSubview:uc4]; 74 | 75 | _uc5 = [[UserControl5 alloc] initWithFrame:CGRectMake(15, 335, 100, 100)]; 76 | _uc5.autoresizingMask = flexmargins; 77 | [v addSubview:_uc5]; 78 | 79 | UserControl6 *uc6 = [[UserControl6 alloc] initWithFrame:CGRectMake(-10, 225, 135, 135)]; 80 | [v addSubview:uc6]; 81 | 82 | v.contentSize = uc1.frame.size; 83 | self.view = v; 84 | } 85 | 86 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 87 | - (void)viewDidLoad 88 | { 89 | [super viewDidLoad]; 90 | 91 | for (UIView *v in self.view.subviews) { 92 | if (![v isKindOfClass:[UIControl class]]) continue; 93 | [(UIControl *)v addTarget:self action:@selector(handleDragInside:withEvent:) forControlEvents:UIControlEventTouchDragInside]; 94 | } 95 | 96 | CABasicAnimation * spin = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 97 | spin.duration = 1; 98 | spin.toValue = [NSNumber numberWithFloat:M_PI]; 99 | spin.cumulative = YES; 100 | spin.repeatCount = MAXFLOAT; 101 | [self.uc5.layer addAnimation:spin forKey:@"spin"]; 102 | } 103 | 104 | - (void)viewDidUnload 105 | { 106 | [super viewDidUnload]; 107 | // Release any retained subviews of the main view. 108 | // e.g. self.myOutlet = nil; 109 | 110 | self.uc5 = nil; 111 | } 112 | 113 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 114 | { 115 | // Return YES for supported orientations 116 | return (interfaceOrientation == UIInterfaceOrientationPortrait); 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl1.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl1.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | @interface UserControl1 : UIView 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl1.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl1.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | #import "AngleGradientLayer.h" 9 | #import "UserControl1.h" 10 | 11 | @implementation UserControl1 12 | 13 | + (Class)layerClass 14 | { 15 | return [AngleGradientLayer class]; 16 | } 17 | 18 | - (id)initWithFrame:(CGRect)frame 19 | { 20 | if (!(self = [super initWithFrame:frame])) 21 | return nil; 22 | 23 | self.backgroundColor = [UIColor whiteColor]; 24 | 25 | NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:16]; 26 | NSMutableArray *locations = [[NSMutableArray alloc] initWithCapacity:16]; 27 | 28 | for (int i = 0; i < 5; i++) { 29 | [colors addObject:(id)[UIColor colorWithRed:252/255.0 green:253/255.0 blue:203/255.0 alpha:1].CGColor]; 30 | [colors addObject:(id)[UIColor colorWithRed:250/255.0 green:96/255.0 blue:53/255.0 alpha:1].CGColor]; 31 | [locations addObject:[NSNumber numberWithFloat:(0.2 * i)]]; 32 | [locations addObject:[NSNumber numberWithFloat:(0.2 * i + 0.16)]]; 33 | } 34 | [colors addObject:(id)[UIColor colorWithRed:252/255.0 green:253/255.0 blue:203/255.0 alpha:1].CGColor]; 35 | [locations addObject:[NSNumber numberWithInt:1]]; 36 | 37 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 38 | l.colors = colors; 39 | l.locations = locations; 40 | 41 | return self; 42 | } 43 | 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl2.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl2.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | @interface UserControl2 : UIControl 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl2.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl2.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | #import "AngleGradientLayer.h" 9 | #import "UserControl2.h" 10 | 11 | 12 | @implementation UserControl2 13 | 14 | + (Class)layerClass 15 | { 16 | return [AngleGradientLayer class]; 17 | } 18 | 19 | - (id)initWithFrame:(CGRect)frame 20 | { 21 | if (!(self = [super initWithFrame:frame])) 22 | return nil; 23 | 24 | self.backgroundColor = [UIColor whiteColor]; 25 | 26 | NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:16]; 27 | 28 | [colors addObject:(id)[UIColor colorWithWhite:0.65 alpha:1].CGColor]; 29 | [colors addObject:(id)[UIColor colorWithWhite:0.9 alpha:1].CGColor]; 30 | [colors addObject:(id)[UIColor colorWithWhite:0.75 alpha:1].CGColor]; 31 | [colors addObject:(id)[UIColor colorWithWhite:0.35 alpha:1].CGColor]; 32 | [colors addObject:(id)[UIColor colorWithWhite:0.75 alpha:1].CGColor]; 33 | [colors addObject:(id)[UIColor colorWithWhite:0.9 alpha:1].CGColor]; 34 | [colors addObject:(id)[UIColor colorWithWhite:0.75 alpha:1].CGColor]; 35 | [colors addObject:(id)[UIColor colorWithWhite:0.35 alpha:1].CGColor]; 36 | [colors addObject:(id)[UIColor colorWithWhite:0.55 alpha:1].CGColor]; 37 | [colors addObject:(id)[UIColor colorWithWhite:0.65 alpha:1].CGColor]; 38 | 39 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 40 | l.colors = colors; 41 | 42 | l.cornerRadius = CGRectGetWidth(self.bounds) / 2; 43 | self.clipsToBounds = YES; 44 | l.borderColor = [UIColor colorWithWhite:0.55 alpha:1].CGColor; 45 | l.borderWidth = 1; 46 | 47 | return self; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl3.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl3.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | @interface UserControl3 : UIControl 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl3.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl3.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | #import "AngleGradientLayer.h" 9 | #import "UserControl3.h" 10 | 11 | 12 | @implementation UserControl3 13 | 14 | + (Class)layerClass 15 | { 16 | return [AngleGradientLayer class]; 17 | } 18 | 19 | - (id)initWithFrame:(CGRect)frame 20 | { 21 | if (!(self = [super initWithFrame:frame])) 22 | return nil; 23 | 24 | self.backgroundColor = [UIColor whiteColor]; 25 | 26 | NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:16]; 27 | 28 | [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:0.5 alpha:1].CGColor]; 29 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0.4 alpha:1].CGColor]; 30 | 31 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 32 | l.colors = colors; 33 | 34 | self.transform = CGAffineTransformMakeRotation(0.75 * M_PI); 35 | 36 | return self; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl4.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl4.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | 9 | @interface UserControl4 : UIControl 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl4.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl4.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | #import "AngleGradientLayer.h" 9 | #import "UserControl4.h" 10 | 11 | 12 | @implementation UserControl4 13 | 14 | + (Class)layerClass 15 | { 16 | return [AngleGradientLayer class]; 17 | } 18 | 19 | - (id)initWithFrame:(CGRect)frame 20 | { 21 | if (!(self = [super initWithFrame:frame])) 22 | return nil; 23 | 24 | self.backgroundColor = [UIColor whiteColor]; 25 | 26 | NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:4]; 27 | 28 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor]; 29 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 30 | [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:0 alpha:1].CGColor]; 31 | [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:1 alpha:1].CGColor]; 32 | [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:1 alpha:1].CGColor]; 33 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:1 alpha:1].CGColor]; 34 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor]; 35 | 36 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 37 | l.colors = colors; 38 | 39 | l.cornerRadius = CGRectGetWidth(self.bounds) / 2; 40 | self.clipsToBounds = YES; 41 | self.transform = CGAffineTransformMakeRotation(-M_PI_2); 42 | 43 | return self; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl5.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl5.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | @interface UserControl5 : UIControl 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl5.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl5.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | #import "AngleGradientLayer.h" 9 | #import "UserControl5.h" 10 | 11 | 12 | @implementation UserControl5 13 | 14 | + (Class)layerClass 15 | { 16 | return [AngleGradientLayer class]; 17 | } 18 | 19 | - (id)initWithFrame:(CGRect)frame 20 | { 21 | if (!(self = [super initWithFrame:frame])) 22 | return nil; 23 | 24 | self.backgroundColor = [UIColor whiteColor]; 25 | 26 | NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:4]; 27 | NSMutableArray *locations = [[NSMutableArray alloc] initWithCapacity:16]; 28 | 29 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor]; 30 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:0 alpha:1].CGColor]; 31 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 32 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 33 | [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:0 alpha:1].CGColor]; 34 | [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:0 alpha:1].CGColor]; 35 | [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:1 alpha:1].CGColor]; 36 | [colors addObject:(id)[UIColor colorWithRed:0 green:1 blue:1 alpha:1].CGColor]; 37 | [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:1 alpha:1].CGColor]; 38 | [colors addObject:(id)[UIColor colorWithRed:0 green:0 blue:1 alpha:1].CGColor]; 39 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:1 alpha:1].CGColor]; 40 | [colors addObject:(id)[UIColor colorWithRed:1 green:0 blue:1 alpha:1].CGColor]; 41 | 42 | [locations addObject:[NSNumber numberWithInt:0]]; 43 | [locations addObject:[NSNumber numberWithFloat:0.158]]; 44 | [locations addObject:[NSNumber numberWithFloat:0.16]]; 45 | [locations addObject:[NSNumber numberWithFloat:0.328]]; 46 | [locations addObject:[NSNumber numberWithFloat:0.33]]; 47 | [locations addObject:[NSNumber numberWithFloat:0.498]]; 48 | [locations addObject:[NSNumber numberWithFloat:0.50]]; 49 | [locations addObject:[NSNumber numberWithFloat:0.658]]; 50 | [locations addObject:[NSNumber numberWithFloat:0.66]]; 51 | [locations addObject:[NSNumber numberWithFloat:0.838]]; 52 | [locations addObject:[NSNumber numberWithFloat:0.84]]; 53 | [locations addObject:[NSNumber numberWithInt:1]]; 54 | 55 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 56 | l.colors = colors; 57 | l.locations = locations; 58 | 59 | l.cornerRadius = CGRectGetWidth(self.bounds) / 2; 60 | self.clipsToBounds = YES; 61 | // self.transform = CGAffineTransformMakeRotation(0.25 * M_PI_2); 62 | 63 | return self; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl6.h: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl6.h 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | @interface UserControl6 : UIControl 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/UserControl6.m: -------------------------------------------------------------------------------- 1 | // 2 | // UserControl6.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-12. 6 | // 7 | 8 | #import "AngleGradientLayer.h" 9 | #import "UserControl6.h" 10 | 11 | 12 | @implementation UserControl6 13 | 14 | + (Class)layerClass 15 | { 16 | return [AngleGradientLayer class]; 17 | } 18 | 19 | - (id)initWithFrame:(CGRect)frame 20 | { 21 | if (!(self = [super initWithFrame:frame])) 22 | return nil; 23 | 24 | self.backgroundColor = [UIColor clearColor]; 25 | 26 | NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:4]; 27 | NSMutableArray *locations = [[NSMutableArray alloc] initWithCapacity:16]; 28 | 29 | for (int i = 0; i < 6; i++) { 30 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 31 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 32 | [colors addObject:(id)[UIColor colorWithRed:1 green:100/255.0 blue:25/255.0 alpha:1].CGColor]; 33 | [colors addObject:(id)[UIColor colorWithRed:1 green:100/255.0 blue:25/255.0 alpha:1].CGColor]; 34 | } 35 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 36 | [colors addObject:(id)[UIColor colorWithRed:1 green:1 blue:0 alpha:1].CGColor]; 37 | 38 | const float fa[] = { 0, 4.0, 5, 29.0, 30, 49.0, 50, 74.0, 75, 104.0, 105, 134.0, 39 | 135, 189.0, 190, 219.0, 220, 254.0, 255, 279.0, 280, 314.0, 315, 339.0, 340, 360 }; 40 | for (int i = 0; i < sizeof(fa)/sizeof(fa[0]); i++) 41 | [locations addObject:[NSNumber numberWithFloat:fa[i] / 360.0]]; 42 | 43 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 44 | l.colors = colors; 45 | l.locations = locations; 46 | 47 | // l.cornerRadius = CGRectGetWidth(self.bounds) / 2; 48 | // self.clipsToBounds = YES; 49 | self.transform = CGAffineTransformMakeRotation(0.25 * M_PI_2); 50 | 51 | return self; 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AngleGradientSample 4 | // 5 | // Created by Pavel Ivashkov on 2012-02-11. 6 | // 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | @autoreleasepool { 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSampleTests/AngleGradientSampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AngleGradientSampleTests.m 3 | // AngleGradientSampleTests 4 | // 5 | // Created by Pavel Ivashkov on 2015-06-29. 6 | // Copyright (c) 2015 paiv. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AngleGradientSampleTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation AngleGradientSampleTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /AngleGradientSample/AngleGradientSampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | paiv.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /AngleGradientSample/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paiv/AngleGradientLayer/3d38a45ec19bfd5e66e96e48a4f7186f2de3d2ca/AngleGradientSample/Default-568h@2x.png -------------------------------------------------------------------------------- /AngleGradientSample/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '6.0' 2 | 3 | pod 'AngleGradientLayer', '~> 1.0' 4 | -------------------------------------------------------------------------------- /ConicSample/ConicSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A55BE8192647BBDF00CC2A4F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE8182647BBDF00CC2A4F /* AppDelegate.swift */; }; 11 | A55BE81D2647BBDF00CC2A4F /* SampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE81C2647BBDF00CC2A4F /* SampleViewController.swift */; }; 12 | A55BE8202647BBDF00CC2A4F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A55BE81E2647BBDF00CC2A4F /* Main.storyboard */; }; 13 | A55BE8222647BBE000CC2A4F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A55BE8212647BBE000CC2A4F /* Assets.xcassets */; }; 14 | A55BE8252647BBE000CC2A4F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A55BE8232647BBE000CC2A4F /* LaunchScreen.storyboard */; }; 15 | A55BE82E2647BDC600CC2A4F /* UserGradient1.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE82D2647BDC600CC2A4F /* UserGradient1.swift */; }; 16 | A55BE8302647BE1700CC2A4F /* UserGradient2.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE82F2647BE1700CC2A4F /* UserGradient2.swift */; }; 17 | A55BE8352647BE4C00CC2A4F /* UserGradient4.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE8312647BE4C00CC2A4F /* UserGradient4.swift */; }; 18 | A55BE8362647BE4C00CC2A4F /* UserGradient3.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE8322647BE4C00CC2A4F /* UserGradient3.swift */; }; 19 | A55BE8372647BE4C00CC2A4F /* UserGradient5.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE8332647BE4C00CC2A4F /* UserGradient5.swift */; }; 20 | A55BE8382647BE4C00CC2A4F /* UserGradient6.swift in Sources */ = {isa = PBXBuildFile; fileRef = A55BE8342647BE4C00CC2A4F /* UserGradient6.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | A55BE8152647BBDF00CC2A4F /* ConicSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ConicSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | A55BE8182647BBDF00CC2A4F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | A55BE81C2647BBDF00CC2A4F /* SampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleViewController.swift; sourceTree = ""; }; 27 | A55BE81F2647BBDF00CC2A4F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | A55BE8212647BBE000CC2A4F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | A55BE8242647BBE000CC2A4F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | A55BE8262647BBE000CC2A4F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | A55BE82D2647BDC600CC2A4F /* UserGradient1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGradient1.swift; sourceTree = ""; }; 32 | A55BE82F2647BE1700CC2A4F /* UserGradient2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserGradient2.swift; sourceTree = ""; }; 33 | A55BE8312647BE4C00CC2A4F /* UserGradient4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserGradient4.swift; sourceTree = ""; }; 34 | A55BE8322647BE4C00CC2A4F /* UserGradient3.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserGradient3.swift; sourceTree = ""; }; 35 | A55BE8332647BE4C00CC2A4F /* UserGradient5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserGradient5.swift; sourceTree = ""; }; 36 | A55BE8342647BE4C00CC2A4F /* UserGradient6.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserGradient6.swift; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | A55BE8122647BBDF00CC2A4F /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | A55BE80C2647BBDF00CC2A4F = { 51 | isa = PBXGroup; 52 | children = ( 53 | A55BE8172647BBDF00CC2A4F /* ConicSample */, 54 | A55BE8162647BBDF00CC2A4F /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | A55BE8162647BBDF00CC2A4F /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | A55BE8152647BBDF00CC2A4F /* ConicSample.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | A55BE8172647BBDF00CC2A4F /* ConicSample */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | A55BE8182647BBDF00CC2A4F /* AppDelegate.swift */, 70 | A55BE8212647BBE000CC2A4F /* Assets.xcassets */, 71 | A55BE82C2647BDAD00CC2A4F /* Gradients */, 72 | A55BE8262647BBE000CC2A4F /* Info.plist */, 73 | A55BE8232647BBE000CC2A4F /* LaunchScreen.storyboard */, 74 | A55BE81E2647BBDF00CC2A4F /* Main.storyboard */, 75 | A55BE81C2647BBDF00CC2A4F /* SampleViewController.swift */, 76 | ); 77 | path = ConicSample; 78 | sourceTree = ""; 79 | }; 80 | A55BE82C2647BDAD00CC2A4F /* Gradients */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | A55BE82D2647BDC600CC2A4F /* UserGradient1.swift */, 84 | A55BE82F2647BE1700CC2A4F /* UserGradient2.swift */, 85 | A55BE8322647BE4C00CC2A4F /* UserGradient3.swift */, 86 | A55BE8312647BE4C00CC2A4F /* UserGradient4.swift */, 87 | A55BE8332647BE4C00CC2A4F /* UserGradient5.swift */, 88 | A55BE8342647BE4C00CC2A4F /* UserGradient6.swift */, 89 | ); 90 | path = Gradients; 91 | sourceTree = ""; 92 | }; 93 | /* End PBXGroup section */ 94 | 95 | /* Begin PBXNativeTarget section */ 96 | A55BE8142647BBDF00CC2A4F /* ConicSample */ = { 97 | isa = PBXNativeTarget; 98 | buildConfigurationList = A55BE8292647BBE000CC2A4F /* Build configuration list for PBXNativeTarget "ConicSample" */; 99 | buildPhases = ( 100 | A55BE8112647BBDF00CC2A4F /* Sources */, 101 | A55BE8122647BBDF00CC2A4F /* Frameworks */, 102 | A55BE8132647BBDF00CC2A4F /* Resources */, 103 | ); 104 | buildRules = ( 105 | ); 106 | dependencies = ( 107 | ); 108 | name = ConicSample; 109 | productName = ConicSample; 110 | productReference = A55BE8152647BBDF00CC2A4F /* ConicSample.app */; 111 | productType = "com.apple.product-type.application"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | A55BE80D2647BBDF00CC2A4F /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | LastSwiftUpdateCheck = 1250; 120 | LastUpgradeCheck = 1250; 121 | TargetAttributes = { 122 | A55BE8142647BBDF00CC2A4F = { 123 | CreatedOnToolsVersion = 12.5; 124 | }; 125 | }; 126 | }; 127 | buildConfigurationList = A55BE8102647BBDF00CC2A4F /* Build configuration list for PBXProject "ConicSample" */; 128 | compatibilityVersion = "Xcode 9.3"; 129 | developmentRegion = en; 130 | hasScannedForEncodings = 0; 131 | knownRegions = ( 132 | en, 133 | Base, 134 | ); 135 | mainGroup = A55BE80C2647BBDF00CC2A4F; 136 | productRefGroup = A55BE8162647BBDF00CC2A4F /* Products */; 137 | projectDirPath = ""; 138 | projectRoot = ""; 139 | targets = ( 140 | A55BE8142647BBDF00CC2A4F /* ConicSample */, 141 | ); 142 | }; 143 | /* End PBXProject section */ 144 | 145 | /* Begin PBXResourcesBuildPhase section */ 146 | A55BE8132647BBDF00CC2A4F /* Resources */ = { 147 | isa = PBXResourcesBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | A55BE8252647BBE000CC2A4F /* LaunchScreen.storyboard in Resources */, 151 | A55BE8222647BBE000CC2A4F /* Assets.xcassets in Resources */, 152 | A55BE8202647BBDF00CC2A4F /* Main.storyboard in Resources */, 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | }; 156 | /* End PBXResourcesBuildPhase section */ 157 | 158 | /* Begin PBXSourcesBuildPhase section */ 159 | A55BE8112647BBDF00CC2A4F /* Sources */ = { 160 | isa = PBXSourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | A55BE8352647BE4C00CC2A4F /* UserGradient4.swift in Sources */, 164 | A55BE8382647BE4C00CC2A4F /* UserGradient6.swift in Sources */, 165 | A55BE82E2647BDC600CC2A4F /* UserGradient1.swift in Sources */, 166 | A55BE8372647BE4C00CC2A4F /* UserGradient5.swift in Sources */, 167 | A55BE8362647BE4C00CC2A4F /* UserGradient3.swift in Sources */, 168 | A55BE8302647BE1700CC2A4F /* UserGradient2.swift in Sources */, 169 | A55BE81D2647BBDF00CC2A4F /* SampleViewController.swift in Sources */, 170 | A55BE8192647BBDF00CC2A4F /* AppDelegate.swift in Sources */, 171 | ); 172 | runOnlyForDeploymentPostprocessing = 0; 173 | }; 174 | /* End PBXSourcesBuildPhase section */ 175 | 176 | /* Begin PBXVariantGroup section */ 177 | A55BE81E2647BBDF00CC2A4F /* Main.storyboard */ = { 178 | isa = PBXVariantGroup; 179 | children = ( 180 | A55BE81F2647BBDF00CC2A4F /* Base */, 181 | ); 182 | name = Main.storyboard; 183 | sourceTree = ""; 184 | }; 185 | A55BE8232647BBE000CC2A4F /* LaunchScreen.storyboard */ = { 186 | isa = PBXVariantGroup; 187 | children = ( 188 | A55BE8242647BBE000CC2A4F /* Base */, 189 | ); 190 | name = LaunchScreen.storyboard; 191 | sourceTree = ""; 192 | }; 193 | /* End PBXVariantGroup section */ 194 | 195 | /* Begin XCBuildConfiguration section */ 196 | A55BE8272647BBE000CC2A4F /* Debug */ = { 197 | isa = XCBuildConfiguration; 198 | buildSettings = { 199 | ALWAYS_SEARCH_USER_PATHS = NO; 200 | CLANG_ANALYZER_NONNULL = YES; 201 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 202 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 203 | CLANG_CXX_LIBRARY = "libc++"; 204 | CLANG_ENABLE_MODULES = YES; 205 | CLANG_ENABLE_OBJC_ARC = YES; 206 | CLANG_ENABLE_OBJC_WEAK = YES; 207 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 208 | CLANG_WARN_BOOL_CONVERSION = YES; 209 | CLANG_WARN_COMMA = YES; 210 | CLANG_WARN_CONSTANT_CONVERSION = YES; 211 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 212 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 213 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INFINITE_RECURSION = YES; 217 | CLANG_WARN_INT_CONVERSION = YES; 218 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 219 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 220 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 221 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 222 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 223 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 224 | CLANG_WARN_STRICT_PROTOTYPES = YES; 225 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 226 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 227 | CLANG_WARN_UNREACHABLE_CODE = YES; 228 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 229 | COPY_PHASE_STRIP = NO; 230 | DEBUG_INFORMATION_FORMAT = dwarf; 231 | ENABLE_STRICT_OBJC_MSGSEND = YES; 232 | ENABLE_TESTABILITY = YES; 233 | GCC_C_LANGUAGE_STANDARD = gnu11; 234 | GCC_DYNAMIC_NO_PIC = NO; 235 | GCC_NO_COMMON_BLOCKS = YES; 236 | GCC_OPTIMIZATION_LEVEL = 0; 237 | GCC_PREPROCESSOR_DEFINITIONS = ( 238 | "DEBUG=1", 239 | "$(inherited)", 240 | ); 241 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 242 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 243 | GCC_WARN_UNDECLARED_SELECTOR = YES; 244 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 245 | GCC_WARN_UNUSED_FUNCTION = YES; 246 | GCC_WARN_UNUSED_VARIABLE = YES; 247 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 248 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 249 | MTL_FAST_MATH = YES; 250 | ONLY_ACTIVE_ARCH = YES; 251 | SDKROOT = iphoneos; 252 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 253 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 254 | }; 255 | name = Debug; 256 | }; 257 | A55BE8282647BBE000CC2A4F /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_ENABLE_OBJC_WEAK = YES; 268 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 269 | CLANG_WARN_BOOL_CONVERSION = YES; 270 | CLANG_WARN_COMMA = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INFINITE_RECURSION = YES; 278 | CLANG_WARN_INT_CONVERSION = YES; 279 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 280 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 281 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 282 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 283 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 284 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 285 | CLANG_WARN_STRICT_PROTOTYPES = YES; 286 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 287 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 288 | CLANG_WARN_UNREACHABLE_CODE = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | COPY_PHASE_STRIP = NO; 291 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 292 | ENABLE_NS_ASSERTIONS = NO; 293 | ENABLE_STRICT_OBJC_MSGSEND = YES; 294 | GCC_C_LANGUAGE_STANDARD = gnu11; 295 | GCC_NO_COMMON_BLOCKS = YES; 296 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 297 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 298 | GCC_WARN_UNDECLARED_SELECTOR = YES; 299 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 300 | GCC_WARN_UNUSED_FUNCTION = YES; 301 | GCC_WARN_UNUSED_VARIABLE = YES; 302 | IPHONEOS_DEPLOYMENT_TARGET = 12.1; 303 | MTL_ENABLE_DEBUG_INFO = NO; 304 | MTL_FAST_MATH = YES; 305 | SDKROOT = iphoneos; 306 | SWIFT_COMPILATION_MODE = wholemodule; 307 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 308 | VALIDATE_PRODUCT = YES; 309 | }; 310 | name = Release; 311 | }; 312 | A55BE82A2647BBE000CC2A4F /* Debug */ = { 313 | isa = XCBuildConfiguration; 314 | buildSettings = { 315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 316 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 317 | CODE_SIGN_STYLE = Automatic; 318 | INFOPLIST_FILE = ConicSample/Info.plist; 319 | LD_RUNPATH_SEARCH_PATHS = ( 320 | "$(inherited)", 321 | "@executable_path/Frameworks", 322 | ); 323 | PRODUCT_BUNDLE_IDENTIFIER = paiv.ConicSample; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SWIFT_VERSION = 5.0; 326 | TARGETED_DEVICE_FAMILY = "1,2"; 327 | }; 328 | name = Debug; 329 | }; 330 | A55BE82B2647BBE000CC2A4F /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 334 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 335 | CODE_SIGN_STYLE = Automatic; 336 | INFOPLIST_FILE = ConicSample/Info.plist; 337 | LD_RUNPATH_SEARCH_PATHS = ( 338 | "$(inherited)", 339 | "@executable_path/Frameworks", 340 | ); 341 | PRODUCT_BUNDLE_IDENTIFIER = paiv.ConicSample; 342 | PRODUCT_NAME = "$(TARGET_NAME)"; 343 | SWIFT_VERSION = 5.0; 344 | TARGETED_DEVICE_FAMILY = "1,2"; 345 | }; 346 | name = Release; 347 | }; 348 | /* End XCBuildConfiguration section */ 349 | 350 | /* Begin XCConfigurationList section */ 351 | A55BE8102647BBDF00CC2A4F /* Build configuration list for PBXProject "ConicSample" */ = { 352 | isa = XCConfigurationList; 353 | buildConfigurations = ( 354 | A55BE8272647BBE000CC2A4F /* Debug */, 355 | A55BE8282647BBE000CC2A4F /* Release */, 356 | ); 357 | defaultConfigurationIsVisible = 0; 358 | defaultConfigurationName = Release; 359 | }; 360 | A55BE8292647BBE000CC2A4F /* Build configuration list for PBXNativeTarget "ConicSample" */ = { 361 | isa = XCConfigurationList; 362 | buildConfigurations = ( 363 | A55BE82A2647BBE000CC2A4F /* Debug */, 364 | A55BE82B2647BBE000CC2A4F /* Release */, 365 | ); 366 | defaultConfigurationIsVisible = 0; 367 | defaultConfigurationName = Release; 368 | }; 369 | /* End XCConfigurationList section */ 370 | }; 371 | rootObject = A55BE80D2647BBDF00CC2A4F /* Project object */; 372 | } 373 | -------------------------------------------------------------------------------- /ConicSample/ConicSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ConicSample/ConicSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ConicSample/ConicSample.xcodeproj/project.xcworkspace/xcuserdata/paiv.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paiv/AngleGradientLayer/3d38a45ec19bfd5e66e96e48a4f7186f2de3d2ca/ConicSample/ConicSample.xcodeproj/project.xcworkspace/xcuserdata/paiv.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ConicSample/ConicSample.xcodeproj/xcuserdata/paiv.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /ConicSample/ConicSample.xcodeproj/xcuserdata/paiv.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ConicSample.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | @UIApplicationMain 5 | class AppDelegate: UIResponder, UIApplicationDelegate { 6 | 7 | var window: UIWindow? 8 | } 9 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/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 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/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 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Gradients/UserGradient1.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | class UserGradient1 : UIView { 5 | 6 | override class var layerClass: AnyClass { 7 | return CAGradientLayer.self 8 | } 9 | 10 | required init?(coder: NSCoder) { 11 | super.init(coder: coder) 12 | 13 | var colors: [CGColor] = [] 14 | var locations: [Double] = [] 15 | for i in 0..<5 { 16 | colors.append(UIColor(red: 252/255, green: 253/255, blue: 203/255, alpha: 1).cgColor) 17 | colors.append(UIColor(red: 250/255, green: 96/255, blue: 53/255, alpha: 1).cgColor) 18 | locations.append(0.2 * Double(i)) 19 | locations.append(0.2 * Double(i) + 0.04) 20 | } 21 | colors.append(UIColor(red: 252/255, green: 253/255, blue: 203/255, alpha: 1).cgColor) 22 | locations.append(1) 23 | 24 | let layer = layer as! CAGradientLayer 25 | layer.type = .conic 26 | layer.startPoint = CGPoint(x: 0.5, y: 0.5) 27 | layer.endPoint = CGPoint(x: 1, y: 0.5) 28 | layer.colors = colors 29 | layer.locations = locations as [NSNumber] 30 | } 31 | 32 | override var frame: CGRect { 33 | didSet { 34 | squareLayer() 35 | } 36 | } 37 | 38 | override var bounds: CGRect { 39 | didSet { 40 | squareLayer() 41 | } 42 | } 43 | 44 | func squareLayer() { 45 | let w = max(bounds.width, bounds.height) 46 | let square = CGRect(x: 0, y: 0, width: w, height: w) 47 | layer.bounds = square 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Gradients/UserGradient2.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | class UserGradient2 : UIControl { 5 | 6 | override class var layerClass: AnyClass { 7 | return CAGradientLayer.self 8 | } 9 | 10 | required init?(coder: NSCoder) { 11 | super.init(coder: coder) 12 | 13 | var colors: [CGColor] = [] 14 | colors.append(UIColor(white:0.65, alpha: 1).cgColor) 15 | colors.append(UIColor(white:0.55, alpha: 1).cgColor) 16 | colors.append(UIColor(white:0.35, alpha: 1).cgColor) 17 | colors.append(UIColor(white:0.75, alpha: 1).cgColor) 18 | colors.append(UIColor(white:0.9, alpha: 1).cgColor) 19 | colors.append(UIColor(white:0.75, alpha: 1).cgColor) 20 | colors.append(UIColor(white:0.35, alpha: 1).cgColor) 21 | colors.append(UIColor(white:0.75, alpha: 1).cgColor) 22 | colors.append(UIColor(white:0.9, alpha: 1).cgColor) 23 | colors.append(UIColor(white:0.65, alpha: 1).cgColor) 24 | 25 | let layer = layer as! CAGradientLayer 26 | layer.type = .conic 27 | layer.startPoint = CGPoint(x: 0.5, y: 0.5) 28 | layer.endPoint = CGPoint(x: 1, y: 0.5) 29 | layer.colors = colors 30 | layer.borderColor = UIColor(white: 0.55, alpha: 1).cgColor 31 | layer.borderWidth = 1 32 | } 33 | 34 | override var frame: CGRect { 35 | didSet { 36 | layer.cornerRadius = bounds.width / 2 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Gradients/UserGradient3.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | class UserGradient3 : UIControl { 5 | 6 | override class var layerClass: AnyClass { 7 | return CAGradientLayer.self 8 | } 9 | 10 | required init?(coder: NSCoder) { 11 | super.init(coder: coder) 12 | 13 | var colors: [CGColor] = [] 14 | colors.append(UIColor(red: 1, green: 1, blue: 0.4, alpha: 1).cgColor) 15 | colors.append(UIColor(red: 0, green: 0, blue: 0.5, alpha: 1).cgColor) 16 | 17 | let layer = layer as! CAGradientLayer 18 | layer.type = .conic 19 | layer.startPoint = CGPoint(x: 0.5, y: 0.5) 20 | layer.endPoint = CGPoint(x: 1, y: 0.5) 21 | layer.colors = colors 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Gradients/UserGradient4.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | class UserGradient4 : UIControl { 5 | 6 | override class var layerClass: AnyClass { 7 | return CAGradientLayer.self 8 | } 9 | 10 | required init?(coder: NSCoder) { 11 | super.init(coder: coder) 12 | 13 | var colors: [CGColor] = [] 14 | colors.append(UIColor(red: 1, green: 0, blue: 0, alpha: 1).cgColor) 15 | colors.append(UIColor(red: 1, green: 0, blue: 1, alpha: 1).cgColor) 16 | colors.append(UIColor(red: 0, green: 0, blue: 1, alpha: 1).cgColor) 17 | colors.append(UIColor(red: 0, green: 1, blue: 1, alpha: 1).cgColor) 18 | colors.append(UIColor(red: 0, green: 1, blue: 0, alpha: 1).cgColor) 19 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 20 | colors.append(UIColor(red: 1, green: 0, blue: 0, alpha: 1).cgColor) 21 | 22 | let layer = layer as! CAGradientLayer 23 | layer.type = .conic 24 | layer.startPoint = CGPoint(x: 0.5, y: 0.5) 25 | layer.endPoint = CGPoint(x: 1, y: 0.5) 26 | layer.colors = colors 27 | layer.transform = CATransform3DMakeRotation(CGFloat.pi * -0.5, 0, 0, 1) 28 | } 29 | 30 | override var frame: CGRect { 31 | didSet { 32 | layer.cornerRadius = bounds.width / 2 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Gradients/UserGradient5.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | class UserGradient5 : UIControl { 5 | 6 | override class var layerClass: AnyClass { 7 | return CAGradientLayer.self 8 | } 9 | 10 | required init?(coder: NSCoder) { 11 | super.init(coder: coder) 12 | 13 | var colors: [CGColor] = [] 14 | colors.append(UIColor(red: 1, green: 0, blue: 1, alpha: 1).cgColor) 15 | colors.append(UIColor(red: 1, green: 0, blue: 1, alpha: 1).cgColor) 16 | colors.append(UIColor(red: 0, green: 0, blue: 1, alpha: 1).cgColor) 17 | colors.append(UIColor(red: 0, green: 0, blue: 1, alpha: 1).cgColor) 18 | colors.append(UIColor(red: 0, green: 1, blue: 1, alpha: 1).cgColor) 19 | colors.append(UIColor(red: 0, green: 1, blue: 1, alpha: 1).cgColor) 20 | colors.append(UIColor(red: 0, green: 1, blue: 0, alpha: 1).cgColor) 21 | colors.append(UIColor(red: 0, green: 1, blue: 0, alpha: 1).cgColor) 22 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 23 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 24 | colors.append(UIColor(red: 1, green: 0, blue: 0, alpha: 1).cgColor) 25 | colors.append(UIColor(red: 1, green: 0, blue: 0, alpha: 1).cgColor) 26 | 27 | var locations: [Double] = [] 28 | locations.append(0) 29 | locations.append(0.16) 30 | locations.append(0.162) 31 | locations.append(0.34) 32 | locations.append(0.342) 33 | locations.append(0.5) 34 | locations.append(0.502) 35 | locations.append(0.67) 36 | locations.append(0.672) 37 | locations.append(0.84) 38 | locations.append(0.842) 39 | locations.append(1) 40 | 41 | let layer = layer as! CAGradientLayer 42 | layer.type = .conic 43 | layer.startPoint = CGPoint(x: 0.5, y: 0.5) 44 | layer.endPoint = CGPoint(x: 1, y: 0.5) 45 | layer.colors = colors 46 | layer.locations = locations as [NSNumber] 47 | layer.transform = CATransform3DMakeRotation(CGFloat.pi * 0.09, 0, 0, 1) 48 | } 49 | 50 | override var frame: CGRect { 51 | didSet { 52 | layer.cornerRadius = bounds.width / 2 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/Gradients/UserGradient6.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | class UserGradient6 : UIControl { 5 | 6 | override class var layerClass: AnyClass { 7 | return CAGradientLayer.self 8 | } 9 | 10 | required init?(coder: NSCoder) { 11 | super.init(coder: coder) 12 | 13 | var colors: [CGColor] = [] 14 | for _ in 0..<6 { 15 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 16 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 17 | colors.append(UIColor(red: 1, green: 100/255, blue: 25/255, alpha: 1).cgColor) 18 | colors.append(UIColor(red: 1, green: 100/255, blue: 25/255, alpha: 1).cgColor) 19 | } 20 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 21 | colors.append(UIColor(red: 1, green: 1, blue: 0, alpha: 1).cgColor) 22 | 23 | let locations: [Double] = [0, 20, 21, 45, 46, 80, 81, 105, 106, 140, 141, 170, 171, 225, 226, 255, 256, 285, 286, 310, 311, 330, 331, 355, 356, 360] 24 | .map { $0 / 360 } 25 | 26 | let layer = layer as! CAGradientLayer 27 | layer.type = .conic 28 | layer.startPoint = CGPoint(x: 0.5, y: 0.5) 29 | layer.endPoint = CGPoint(x: 1, y: 0.5) 30 | layer.colors = colors 31 | layer.locations = locations as [NSNumber] 32 | layer.transform = CATransform3DMakeRotation(CGFloat.pi * 0.125, 0, 0, 1) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/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 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSupportsIndirectInputEvents 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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ConicSample/ConicSample/SampleViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class SampleViewController: UIViewController { 4 | 5 | override func viewDidLoad() { 6 | super.viewDidLoad() 7 | 8 | for view in self.view.subviews { 9 | if let control = view as? UIControl { 10 | control.addTarget(self, action: #selector(handleDragInside(sender:forEvent:)), for: .touchDragInside) 11 | } 12 | } 13 | } 14 | 15 | @IBAction func handleDragInside(sender: UIControl, forEvent event: UIEvent) { 16 | sender.superview?.bringSubviewToFront(sender) 17 | if let touch = event.allTouches?.first { 18 | sender.center = touch.location(in: sender.superview!) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ConicSample/readme.md: -------------------------------------------------------------------------------- 1 | Demonstration of `iOS 12` [CAGradientLayer](https://developer.apple.com/documentation/quartzcore/cagradientlayer) layer type [.conic](https://developer.apple.com/documentation/quartzcore/cagradientlayertype) 2 | 3 | ![screenshot](screenshot.png) 4 | -------------------------------------------------------------------------------- /ConicSample/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paiv/AngleGradientLayer/3d38a45ec19bfd5e66e96e48a4f7186f2de3d2ca/ConicSample/screenshot.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (C) 2012 Pavel Ivashkov 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | and associated documentation files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or 13 | substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 18 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Deprecation 2 | 3 | This library is deprecated in favor of `iOS 12` [CAGradientLayer](https://developer.apple.com/documentation/quartzcore/cagradientlayer) layer type [.conic](https://developer.apple.com/documentation/quartzcore/cagradientlayertype) 4 | 5 | See [ConicSample project](ConicSample/) for `CAGradientLayer` examples ported from `AngleGradientLayer`. 6 | 7 | 8 | [![standwithukraine](https://user-images.githubusercontent.com/196601/158214305-7c94dd27-40a7-4af6-929b-38928700938b.svg)](https://ukrainewar.carrd.co/) 9 | [![cocoapods](https://img.shields.io/cocoapods/v/AngleGradientLayer.svg)](https://cocoapods.org/pods/AngleGradientLayer) 10 | 11 | # AngleGradientLayer 12 | 13 | **AngleGradientLayer** is a **CALayer** implementation of angle gradient. 14 | 15 | ![screenshot](https://github.com/paiv/AngleGradientLayer/raw/master/screenshot.png) 16 | 17 | ## Installing 18 | 19 | ```ruby 20 | pod 'AngleGradientLayer', '~> 1.0' 21 | ``` 22 | 23 | ## [Swift] Using in your code 24 | 25 | ```swift 26 | import AngleGradientLayer 27 | 28 | class MyView: UIView { 29 | 30 | override class func layerClass() -> AnyClass { 31 | return AngleGradientLayer.self 32 | } 33 | 34 | override init(frame: CGRect) { 35 | super.init(frame: frame) 36 | 37 | let l: AngleGradientLayer = self.layer as! AngleGradientLayer 38 | l.colors = [ 39 | UIColor(red: 0, green: 0, blue: 0.5, alpha: 1).CGColor, 40 | UIColor(red: 1, green: 1, blue: 0.4, alpha: 1).CGColor] 41 | } 42 | } 43 | ``` 44 | 45 | ## [Objective-C] Using in your code 46 | 47 | (See demo project for more.) 48 | 49 | ```objective-c 50 | #import "AngleGradientLayer.h" 51 | 52 | @interface MyView : UIView 53 | @end 54 | 55 | @implementation MyView 56 | 57 | + (Class)layerClass 58 | { 59 | return [AngleGradientLayer class]; 60 | } 61 | 62 | - (id)initWithFrame:(CGRect)frame 63 | { 64 | if (!(self = [super initWithFrame:frame])) 65 | return nil; 66 | 67 | AngleGradientLayer *l = (AngleGradientLayer *)self.layer; 68 | l.colors = [NSArray arrayWithObjects: 69 | (id)[UIColor colorWithRed:0 green:0 blue:0.5 alpha:1].CGColor, 70 | (id)[UIColor colorWithRed:1 green:1 blue:0.4 alpha:1].CGColor, 71 | nil]; 72 | 73 | return self; 74 | } 75 | 76 | @end 77 | ``` 78 | 79 | ## Notes 80 | 81 | When working with semi-transparent views, be sure to set `backgroundColor` property on the layer's view 82 | 83 | ```swift 84 | myview.backgroundColor = UIColor.clearColor() 85 | ``` 86 | 87 | `backgroundColor` by default is `nil`, blending to black color. 88 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paiv/AngleGradientLayer/3d38a45ec19bfd5e66e96e48a4f7186f2de3d2ca/screenshot.png --------------------------------------------------------------------------------