Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radial Gradients #527

Merged
merged 5 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ N/A

- Add new mask types `.drop`, `.plusSign`, `.moon`. [#519](https://github.com/IBAnimatable/IBAnimatable/pull/519) by [@phimage](https://github.com/phimage)
- Add new mask types `.heart`, `.gear`, `.ring`, `.superEllipse`. [#518](https://github.com/IBAnimatable/IBAnimatable/pull/518) by [@phimage](https://github.com/phimage)
- Add suppport for radial gradient. Currently not working with `startPoint`. [#527](https://github.com/IBAnimatable/IBAnimatable/pull/527) by [@tbaranes](https://github.com/tbaranes)

#### Bugfixes

Expand Down
1 change: 1 addition & 0 deletions Documentation/APIs.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ To use `IBAnimatable`, we can drag and drop a UIKit element and connect it with
#### `GradientDesignable`
| Property name | Data type | Description |
| ------------- |:-------------:| ----- |
| gradientMode | Optional<GradientMode> | Gradient mode. All gradient mode are in enum [`GradientMode`](../IBAnimatable/GradientMode.swift), default value is `.linear`. |
| startColor | Optional<UIColor> | start gradient color |
| endColor | Optional<UIColor> | end gradient color |
| predefinedGradient | Optional<String> | Predefined gradients. All predefined gradients are in enum [`GradientType`](../IBAnimatable/GradientType.swift), To find the predefined gradients, you can use [uigradients.com](http://uigradients.com), e.g. `Juicy Orange` on the website maps to `JuicyOrange` in the enum. |
Expand Down
8 changes: 8 additions & 0 deletions IBAnimatable/IBAnimatable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
C4511F371F93F1B2002E0FAF /* UIBezierPathExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4511F361F93F1B2002E0FAF /* UIBezierPathExtension.swift */; };
E20DAEB82003662900BE1C88 /* GradientMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = E20DAEB72003662900BE1C88 /* GradientMode.swift */; };
E20DAEBA2003682F00BE1C88 /* RadialGradientLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E20DAEB92003682F00BE1C88 /* RadialGradientLayer.swift */; };
E2561F5F1ECD7DD900A6D853 /* IBAnimatable.h in Headers */ = {isa = PBXBuildFile; fileRef = E2561F5D1ECD7DD900A6D853 /* IBAnimatable.h */; settings = {ATTRIBUTES = (Public, ); }; };
E27FD0011ECD79DD00F74840 /* IBAnimatable.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E27FCFF71ECD79DD00F74840 /* IBAnimatable.framework */; };
E27FD02C1ECD7BCE00F74840 /* ColorTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E27FD0121ECD7BCE00F74840 /* ColorTypeTests.swift */; };
Expand Down Expand Up @@ -200,6 +202,8 @@

/* Begin PBXFileReference section */
C4511F361F93F1B2002E0FAF /* UIBezierPathExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIBezierPathExtension.swift; sourceTree = "<group>"; };
E20DAEB72003662900BE1C88 /* GradientMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientMode.swift; sourceTree = "<group>"; };
E20DAEB92003682F00BE1C88 /* RadialGradientLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadialGradientLayer.swift; sourceTree = "<group>"; };
E2561F5D1ECD7DD900A6D853 /* IBAnimatable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IBAnimatable.h; sourceTree = "<group>"; };
E2561F5E1ECD7DD900A6D853 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E27FCFF71ECD79DD00F74840 /* IBAnimatable.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = IBAnimatable.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -679,6 +683,7 @@
E27FD1E01ECD7D8A00F74840 /* CornerSide.swift */,
E27FD1E11ECD7D8A00F74840 /* GradientStartPoint.swift */,
E27FD1E21ECD7D8A00F74840 /* GradientType.swift */,
E20DAEB72003662900BE1C88 /* GradientMode.swift */,
E27FD1E31ECD7D8A00F74840 /* IBEnum.swift */,
E27FD1E41ECD7D8A00F74840 /* InteractiveGestureType.swift */,
E27FD1E51ECD7D8A00F74840 /* MaskType.swift */,
Expand Down Expand Up @@ -709,6 +714,7 @@
isa = PBXGroup;
children = (
E27FD1F31ECD7D8A00F74840 /* AnimationChainable.swift */,
E20DAEB92003682F00BE1C88 /* RadialGradientLayer.swift */,
);
path = Others;
sourceTree = "<group>";
Expand Down Expand Up @@ -1054,6 +1060,7 @@
E27FD2921ECD7D8A00F74840 /* UIColorExtension.swift in Sources */,
E27FD2751ECD7D8A00F74840 /* Typealias.swift in Sources */,
E27FD2C51ECD7D8A00F74840 /* AnimatableBarButtonItem.swift in Sources */,
E20DAEB82003662900BE1C88 /* GradientMode.swift in Sources */,
E27FD2C01ECD7D8A00F74840 /* PresentSlideSegue.swift in Sources */,
E27FD2BC1ECD7D8A00F74840 /* PresentNatGeoSegue.swift in Sources */,
E27FD2AE1ECD7D8A00F74840 /* ViewControllerDesignable.swift in Sources */,
Expand Down Expand Up @@ -1122,6 +1129,7 @@
E27FD2C21ECD7D8A00F74840 /* PresentTurnSegue.swift in Sources */,
E27FD2611ECD7D8A00F74840 /* TransitionPresenter.swift in Sources */,
E27FD28D1ECD7D8A00F74840 /* TimingFunctionType.swift in Sources */,
E20DAEBA2003682F00BE1C88 /* RadialGradientLayer.swift in Sources */,
E27FD2CB1ECD7D8A00F74840 /* AnimatableScrollView.swift in Sources */,
E27FD2C41ECD7D8A00F74840 /* AnimatableActivityIndicatorView.swift in Sources */,
E27FD2911ECD7D8A00F74840 /* CALayerExtension.swift in Sources */,
Expand Down
22 changes: 19 additions & 3 deletions IBAnimatableApp/IBAnimatableApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
E20DAEBD20037C5E00BE1C88 /* UserInterfaceGradients.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E20DAEBC20037C5E00BE1C88 /* UserInterfaceGradients.storyboard */; };
E20DAEBF20037C7800BE1C88 /* UserInterfaceGradientsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E20DAEBE20037C7800BE1C88 /* UserInterfaceGradientsTableViewController.swift */; };
E2307A311ECD81D6000E38B2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2307A2B1ECD81D6000E38B2 /* Assets.xcassets */; };
E2307A331ECD81D6000E38B2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2307A2E1ECD81D6000E38B2 /* LaunchScreen.storyboard */; };
E2307A621ECD8278000E38B2 /* DemoApp.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2307A381ECD8278000E38B2 /* DemoApp.storyboard */; };
Expand Down Expand Up @@ -65,6 +67,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
E20DAEBC20037C5E00BE1C88 /* UserInterfaceGradients.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = UserInterfaceGradients.storyboard; sourceTree = "<group>"; };
E20DAEBE20037C7800BE1C88 /* UserInterfaceGradientsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInterfaceGradientsTableViewController.swift; sourceTree = "<group>"; };
E2307A151ECD7F81000E38B2 /* IBAnimatableApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IBAnimatableApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
E2307A2B1ECD81D6000E38B2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E2307A2F1ECD81D6000E38B2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -121,6 +125,17 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
E20DAEBB20037C4200BE1C88 /* Gradients */ = {
isa = PBXGroup;
children = (
E20DAEBC20037C5E00BE1C88 /* UserInterfaceGradients.storyboard */,
E20DAEBE20037C7800BE1C88 /* UserInterfaceGradientsTableViewController.swift */,
E2A5476D1ECF1C4400842C1F /* GradientViewController.swift */,
E2A5476C1ECF1C4400842C1F /* GradientCustomStartPointViewController.swift */,
);
path = Gradients;
sourceTree = "<group>";
};
E2307A0C1ECD7F81000E38B2 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -254,13 +269,12 @@
isa = PBXGroup;
children = (
E2A5476E1ECF1C4400842C1F /* Mask */,
E20DAEBB20037C4200BE1C88 /* Gradients */,
E2A547711ECF1C4400842C1F /* UserInterface.storyboard */,
E2A547721ECF1C4400842C1F /* UserInterfaceTableViewController.swift */,
E2A547691ECF1C4400842C1F /* BlurEffectViewController.swift */,
E2A5476A1ECF1C4400842C1F /* BorderViewController.swift */,
E2A5476B1ECF1C4400842C1F /* CornerViewController.swift */,
E2A5476C1ECF1C4400842C1F /* GradientCustomStartPointViewController.swift */,
E2A5476D1ECF1C4400842C1F /* GradientViewController.swift */,
E2A547721ECF1C4400842C1F /* UserInterfaceTableViewController.swift */,
);
path = UserInterfaces;
sourceTree = "<group>";
Expand Down Expand Up @@ -362,6 +376,7 @@
E2A5477A1ECF1C4400842C1F /* UserInterface.storyboard in Resources */,
E2307A311ECD81D6000E38B2 /* Assets.xcassets in Resources */,
E2A5477F1ECF1C4E00842C1F /* ActivityIndicators.storyboard in Resources */,
E20DAEBD20037C5E00BE1C88 /* UserInterfaceGradients.storyboard in Resources */,
E2307A8B1ECD8736000E38B2 /* Main.storyboard in Resources */,
E2A547371ECF1C0E00842C1F /* Presentations.storyboard in Resources */,
E2307A621ECD8278000E38B2 /* DemoApp.storyboard in Resources */,
Expand Down Expand Up @@ -408,6 +423,7 @@
E2A5474C1ECF1C0E00842C1F /* Functions.swift in Sources */,
E2A547301ECF1C0E00842C1F /* AnimationsViewController.swift in Sources */,
E2A547341ECF1C0E00842C1F /* InteractionTableViewController.swift in Sources */,
E20DAEBF20037C7800BE1C88 /* UserInterfaceGradientsTableViewController.swift in Sources */,
E2A5473B1ECF1C0E00842C1F /* RefreshControlTableViewController.swift in Sources */,
E2A547761ECF1C4400842C1F /* GradientCustomStartPointViewController.swift in Sources */,
E2A547381ECF1C0E00842C1F /* PresentingViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class GradientCustomStartPointViewController: UIViewController {

@IBOutlet fileprivate weak var gView: AnimatableView!

var useRadialGradient = false
let gradientValues = ParamType(fromEnum: GradientType.self)
let coordPointValues = ParamType.number(min: 0, max: 1, interval: 0.1, ascending: true, unit: "")
lazy var componentValues: [ParamType] = [self.gradientValues,
Expand All @@ -23,6 +24,7 @@ final class GradientCustomStartPointViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
gView.gradientMode = useRadialGradient ? .radial : .linear
gView.predefinedGradient = GradientType(rawValue: gradientValues.value(at: 0))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ final class GradientViewController: UIViewController {
let startPointValues = ParamType.enumeration(values: ["top", "topLeft", "topRight", "left", "right", "bottom", "bottomRight", "bottomLeft"])
let colorValues = ParamType(fromEnum: ColorType.self)
var usePredefinedGradient = true
var useRadialGradient = false
lazy var componentValues: [ParamType] = {
self.usePredefinedGradient ? [self.gradientValues, self.startPointValues] : [self.colorValues, self.colorValues, self.startPointValues]
}()

override func viewDidLoad() {
super.viewDidLoad()
gView.gradientMode = useRadialGradient ? .radial : .linear
if usePredefinedGradient {
gView.predefinedGradient = GradientType(rawValue: gradientValues.value(at: 0))
gView.startPoint = GradientStartPoint(string: startPointValues.value(at: 0))
Expand Down