Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 310406d

Browse files
committed
Changed CornerRadius to ShadowRadius.
1 parent 4d04104 commit 310406d

File tree

2 files changed

+77
-65
lines changed

2 files changed

+77
-65
lines changed

Effects/ShadowEffect/iOS/LabelShadowEffect.cs

100755100644
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,33 @@
55
using Xamarin.Forms;
66
using Xamarin.Forms.Platform.iOS;
77

8-
[assembly:ResolutionGroupName ("MyCompany")]
9-
[assembly:ExportEffect (typeof(LabelShadowEffect), "LabelShadowEffect")]
8+
[assembly: ResolutionGroupName("MyCompany")]
9+
[assembly: ExportEffect(typeof(LabelShadowEffect), "LabelShadowEffect")]
1010
namespace EffectsDemo.iOS
1111
{
12-
public class LabelShadowEffect : PlatformEffect
13-
{
14-
protected override void OnAttached ()
15-
{
16-
try {
17-
var effect = (ShadowEffect)Element.Effects.FirstOrDefault (e => e is ShadowEffect);
18-
if (effect != null) {
19-
Control.Layer.CornerRadius = effect.Radius;
20-
Control.Layer.ShadowColor = effect.Color.ToCGColor ();
21-
Control.Layer.ShadowOffset = new CGSize (effect.DistanceX, effect.DistanceY);
22-
Control.Layer.ShadowOpacity = 1.0f;
23-
}
24-
} catch (Exception ex) {
25-
Console.WriteLine ("Cannot set property on attached control. Error: ", ex.Message);
26-
}
27-
}
12+
public class LabelShadowEffect : PlatformEffect
13+
{
14+
protected override void OnAttached()
15+
{
16+
try
17+
{
18+
var effect = (ShadowEffect)Element.Effects.FirstOrDefault(e => e is ShadowEffect);
19+
if (effect != null)
20+
{
21+
Control.Layer.ShadowRadius = effect.Radius;
22+
Control.Layer.ShadowColor = effect.Color.ToCGColor();
23+
Control.Layer.ShadowOffset = new CGSize(effect.DistanceX, effect.DistanceY);
24+
Control.Layer.ShadowOpacity = 1.0f;
25+
}
26+
}
27+
catch (Exception ex)
28+
{
29+
Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
30+
}
31+
}
2832

29-
protected override void OnDetached ()
30-
{
31-
}
32-
}
33+
protected override void OnDetached()
34+
{
35+
}
36+
}
3337
}

Effects/ShadowEffectRuntimeChange/iOS/LabelShadowEffect.cs

100755100644
Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,62 @@
66
using Xamarin.Forms;
77
using Xamarin.Forms.Platform.iOS;
88

9-
[assembly:ResolutionGroupName ("MyCompany")]
10-
[assembly:ExportEffect (typeof(LabelShadowEffect), "LabelShadowEffect")]
9+
[assembly: ResolutionGroupName("MyCompany")]
10+
[assembly: ExportEffect(typeof(LabelShadowEffect), "LabelShadowEffect")]
1111
namespace EffectsDemo.iOS
1212
{
13-
[Preserve(AllMembers = true)]
14-
public class LabelShadowEffect : PlatformEffect
15-
{
16-
protected override void OnAttached ()
17-
{
18-
try {
19-
UpdateRadius ();
20-
UpdateColor ();
21-
UpdateOffset ();
22-
Control.Layer.ShadowOpacity = 1.0f;
23-
} catch (Exception ex) {
24-
Console.WriteLine ("Cannot set property on attached control. Error: ", ex.Message);
25-
}
26-
}
13+
[Preserve(AllMembers = true)]
14+
public class LabelShadowEffect : PlatformEffect
15+
{
16+
protected override void OnAttached()
17+
{
18+
try
19+
{
20+
UpdateRadius();
21+
UpdateColor();
22+
UpdateOffset();
23+
Control.Layer.ShadowOpacity = 1.0f;
24+
}
25+
catch (Exception ex)
26+
{
27+
Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
28+
}
29+
}
2730

28-
protected override void OnDetached ()
29-
{
30-
}
31+
protected override void OnDetached()
32+
{
33+
}
3134

32-
protected override void OnElementPropertyChanged (PropertyChangedEventArgs args)
33-
{
34-
if (args.PropertyName == ShadowEffect.RadiusProperty.PropertyName) {
35-
UpdateRadius ();
36-
} else if (args.PropertyName == ShadowEffect.ColorProperty.PropertyName) {
37-
UpdateColor ();
38-
} else if (args.PropertyName == ShadowEffect.DistanceXProperty.PropertyName ||
39-
args.PropertyName == ShadowEffect.DistanceYProperty.PropertyName) {
40-
UpdateOffset ();
41-
}
42-
}
35+
protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
36+
{
37+
if (args.PropertyName == ShadowEffect.RadiusProperty.PropertyName)
38+
{
39+
UpdateRadius();
40+
}
41+
else if (args.PropertyName == ShadowEffect.ColorProperty.PropertyName)
42+
{
43+
UpdateColor();
44+
}
45+
else if (args.PropertyName == ShadowEffect.DistanceXProperty.PropertyName ||
46+
args.PropertyName == ShadowEffect.DistanceYProperty.PropertyName)
47+
{
48+
UpdateOffset();
49+
}
50+
}
4351

44-
void UpdateRadius ()
45-
{
46-
Control.Layer.CornerRadius = (nfloat)ShadowEffect.GetRadius (Element);
47-
}
52+
void UpdateRadius()
53+
{
54+
Control.Layer.ShadowRadius = (nfloat)ShadowEffect.GetRadius(Element);
55+
}
4856

49-
void UpdateColor ()
50-
{
51-
Control.Layer.ShadowColor = ShadowEffect.GetColor (Element).ToCGColor ();
52-
}
57+
void UpdateColor()
58+
{
59+
Control.Layer.ShadowColor = ShadowEffect.GetColor(Element).ToCGColor();
60+
}
5361

54-
void UpdateOffset ()
55-
{
56-
Control.Layer.ShadowOffset = new CGSize ((double)ShadowEffect.GetDistanceX (Element), (double)ShadowEffect.GetDistanceY (Element));
57-
}
58-
}
62+
void UpdateOffset()
63+
{
64+
Control.Layer.ShadowOffset = new CGSize((double)ShadowEffect.GetDistanceX(Element), (double)ShadowEffect.GetDistanceY(Element));
65+
}
66+
}
5967
}

0 commit comments

Comments
 (0)