private void UpdateCornerRadius() { var cornerRadius = (Element as CustomFrame)?.CornerRadius; if (!cornerRadius.HasValue) { return; } var roundedCornerRadius = RetrieveCommonCornerRadius(cornerRadius.Value); if (roundedCornerRadius <= 0) { return; } var roundedCorners = RetrieveRoundedCorners(cornerRadius.Value); var path = UIBezierPath.FromRoundedRect(Bounds, roundedCorners, new CGSize(roundedCornerRadius, roundedCornerRadius)); var mask = new CAShapeLayer { Path = path.CGPath }; mask.ShadowRadius = 0.0f; mask.ShadowColor = CGColor.CreateSrgb(0, 0, 0, 0); NativeView.Layer.Mask = mask; }
public void CreateSrgb() { TestRuntime.AssertXcodeVersion(11, 0); using (var c = CGColor.CreateSrgb(0.1f, 0.2f, 0.3f, 0.4f)) { Assert.That(c.NumberOfComponents, Is.EqualTo((nint)4), "NumberOfComponents"); Assert.That(c.Alpha, Is.InRange((nfloat)0.4f, (nfloat)0.40001f), "Alpha"); Assert.That(c.ColorSpace.Model, Is.EqualTo(CGColorSpaceModel.RGB), "CGColorSpaceModel"); } }
public void CreateByMatchingToColorSpace() { TestRuntime.AssertXcodeVersion(8, 0); using (var c = CGColor.CreateByMatchingToColorSpace(null, CGColorRenderingIntent.Default, null, null)) { Assert.IsNull(c, "0"); } using (var cs = CGColorSpace.CreateGenericRgbLinear()) using (var c1 = CGColor.CreateSrgb(1, 2, 3, 4)) using (var c2 = CGColor.CreateByMatchingToColorSpace(cs, CGColorRenderingIntent.Default, c1, null)) { Assert.IsNotNull(c1, "1"); Assert.IsNotNull(c2, "2"); } }
protected void CreateGradientLayer() { // Gradient overlay for duration _gradientLayer = new CAGradientLayer { Frame = new CGRect(0, 0, CellHeight - 18, CellHeight - 18), Locations = new[] { new NSNumber(0.0f), new NSNumber(1.0f) }, Colors = new[] { UIColor.Clear.CGColor, CGColor.CreateSrgb(0, 0, 0, 0.6f) } }; // Add the gradient view and bring it to the front over the image _imageControl.Layer.InsertSublayer(_gradientLayer, 0); _imageControl.BringSubviewToFront(_rightFooter); _imageControl.BringSubviewToFront(_leftFooter); }