本文整理汇总了C#中CALayer类的典型用法代码示例。如果您正苦于以下问题:C# CALayer类的具体用法?C# CALayer怎么用?C# CALayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CALayer类属于命名空间,在下文中一共展示了CALayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
TKChart chart = new TKChart (this.View.Bounds);
chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
this.View.AddSubview (chart);
string[] months = new string[]{ "Jan", "Feb", "Mar", "Apr", "May", "Jun" };
int[] values = new int[]{ 95, 40, 55, 30, 76, 34 };
List<TKChartDataPoint> list = new List<TKChartDataPoint> ();
for (int i = 0; i < months.Length; i++) {
list.Add (new TKChartDataPoint(new NSString(months[i]), new NSNumber(values[i])));
}
chart.AddSeries (new TKChartAreaSeries (list.ToArray()));
CALayer layer = new CALayer ();
layer.Bounds = new RectangleF (0, 0, 100, 100);
layer.BackgroundColor = new UIColor(1, 0, 0, 0.6f).CGColor;
layer.ShadowRadius = 10;
layer.ShadowColor = UIColor.Yellow.CGColor;
layer.ShadowOpacity = 1;
layer.CornerRadius = 10;
TKChartLayerAnnotation a = new TKChartLayerAnnotation(layer, new NSString("Mar"), new NSNumber(80), chart.Series[0]);
a.ZPosition = TKChartAnnotationZPosition.AboveSeries;
chart.AddAnnotation(a);
}
示例2: OuterShadow
public OuterShadow(CALayer targetLayer, SizeF frameSize, float shadowDepth)
{
this.targetLayer = targetLayer;
FrameSize = frameSize;
ShadowDepth = shadowDepth;
shadows[Edge.Top] = shadows[Edge.Right] = shadows[Edge.Bottom] = shadows[Edge.Left] = null;
}
示例3: Draw
public static void Draw(CALayer target, IViewport viewport, IStyle style, IFeature feature)
{
const string styleKey = "laag";
if(feature[styleKey] == null) feature[styleKey] = ToiOSBitmap(feature.Geometry);
var bitmap = (UIImage)feature [styleKey];
var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
dest = new BoundingBox(
dest.MinX,
dest.MinY,
dest.MaxX,
dest.MaxY);
var destination = RoundToPixel(dest);
var tile = new CALayer
{
Frame = destination,
Contents = bitmap.CGImage,
};
target.AddSublayer(tile);
}
示例4: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
sessionManager = new SessionManager ();
sessionManager.StartRunning ();
previewLayer = new AVCaptureVideoPreviewLayer (sessionManager.CaptureSession) {
Frame = previewView.Bounds,
VideoGravity = AVLayerVideoGravity.ResizeAspectFill
};
if (previewLayer.Connection != null && previewLayer.Connection.SupportsVideoOrientation)
previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.LandscapeLeft;
previewView.Layer.AddSublayer (previewLayer);
previewView.Layer.MasksToBounds = true;
barcodeTargetLayer = new CALayer () {
Frame = View.Layer.Bounds
};
View.Layer.AddSublayer (barcodeTargetLayer);
synth = new Synth ();
synth.LoadPreset (this);
// the loop that continuously looks for barcodes to detect
stepTimer = NSTimer.CreateScheduledTimer (0.15, this, new Selector ("step:"), null, true);
}
示例5: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
sessionManager = new SessionManager ();
sessionManager.StartRunning ();
previewLayer = new AVCaptureVideoPreviewLayer (sessionManager.CaptureSession) {
Frame = previewView.Bounds,
VideoGravity = AVLayerVideoGravity.ResizeAspectFill
};
if (previewLayer.Connection != null && previewLayer.Connection.SupportsVideoOrientation)
previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.LandscapeLeft;
previewView.Layer.AddSublayer (previewLayer);
previewView.Layer.MasksToBounds = true;
barcodeTargetLayer = new CALayer () {
Frame = View.Layer.Bounds
};
View.Layer.AddSublayer (barcodeTargetLayer);
synth = new Synth ();
synth.LoadPreset (this);
}
示例6: PositionMultiPolygon
public static void PositionMultiPolygon(CALayer shape, MultiPolygon multiPolygon, IStyle style, IViewport viewport)
{
var shapeLayer = shape as CAShapeLayer;
var path = multiPolygon.ToUIKit(viewport);
//var frame = ConvertBoundingBox (multiPolygon.GetBoundingBox(), viewport);
shapeLayer.Path = path.CGPath;
//shape.Frame = frame;
/*
if (viewport.Resolution > MinResolution || viewport.Resolution < MaxResolution) {
//recalculate
var newImage = RenderMultiPolygonOnLayer (multiPolygon, style, viewport);
shape.Contents = newImage.Contents;
shape.Frame = newImage.Frame;
var resolution = ZoomHelper.ClipResolutionToExtremes (Resolutions, viewport.Resolution);
MinResolution = ZoomHelper.ZoomOut (Resolutions, resolution);
MaxResolution = ZoomHelper.ZoomIn (Resolutions, resolution);
} else {
//reposition Geometry
var frame = ConvertBoundingBox (multiPolygon.GetBoundingBox(), viewport);
var newFrame = new RectangleF (frame.X, (frame.Y), frame.Width, frame.Height);
shape.Frame = newFrame;
//shape.Frame = frame;
}
*/
}
示例7: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.NewElement != null && !isInitialized)
{
var formsEntry = e.NewElement as LoginEntry;
formsEntry.FontFamily = "SegoeUI-Light";
formsEntry.TextColor = Color.FromHex("#778687");
formsEntry.FontSize = 18;
nativeTextField = Control as UITextField;
nativeTextField.BorderStyle = UITextBorderStyle.None;
//Figure out how to reference font from Resources as Embedded Resource
if (!String.IsNullOrEmpty(formsEntry.Placeholder))
nativeTextField.AttributedPlaceholder = new NSAttributedString(formsEntry.Placeholder, UIFont.FromName("SegoeUI-Light", 18), Color.FromHex("#778687").ToUIColor());
bottomBorder = new CALayer();
bottomBorder.BackgroundColor = Color.FromHex("#778687").ToCGColor();
Control.Layer.AddSublayer(bottomBorder);
isInitialized = true;
}
}
示例8: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
View.BackgroundColor = UIColor.White;
View.UserInteractionEnabled = true;
layer = new CALayer {
Bounds = new CGRect (0, 0, 50, 50),
Position = new CGPoint (50, 50),
Contents = UIImage.FromFile ("monkey2.png").CGImage,
ContentsGravity = CALayer.GravityResize,
BorderWidth = 1.5f,
BorderColor = UIColor.Green.CGColor
};
View.Layer.AddSublayer (layer);
View.AddGestureRecognizer (new UITapGestureRecognizer (() => {
ViewController initalViewController = (ViewController)MainStoryboard.InstantiateViewController("InitalViewController");
initalViewController.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
PresentViewController(initalViewController, true, null);
}));
}
示例9: AddBorder
public static void AddBorder(this UIView view, UIRectEdge edge, UIColor color, nfloat thickness) {
var border = new CALayer ();
var f = view.Frame;
switch(edge)
{
case UIRectEdge.Top:
border.Frame = new CGRect(0, 0, f.Width, thickness);
break;
case UIRectEdge.Bottom:
border.Frame = new CGRect (0, f.Height - thickness, f.Width, thickness);
break;
case UIRectEdge.Left:
border.Frame = new CGRect(0, 0, thickness, f.Height);
break;
case UIRectEdge.Right:
border.Frame = new CGRect(f.Width - thickness, 0, thickness, f.Height);
break;
default:
break;
}
border.BackgroundColor = color.CGColor;
view.Layer.AddSublayer (border);
}
示例10: ShimmeringMaskLayer
public ShimmeringMaskLayer()
{
FadeLayer = new CALayer();
FadeLayer.BackgroundColor = UIColor.White.CGColor;
AddSublayer(FadeLayer);
RemoveAllAnimations();
}
示例11: Clone
public override void Clone (CALayer other)
{
CircleLayer o = (CircleLayer) other;
Radius = o.Radius;
Color = o.Color;
Thickness = o.Thickness;
base.Clone (other);
}
示例12: AwakeFromNib
public override void AwakeFromNib()
{
base.AwakeFromNib();
View.Layer = new CALayer();
View.WantsLayer = true;
textContainer = new CALayer();
textContainer.AnchorPoint = CGPoint.Empty;
textContainer.Position = new CGPoint(10, 10);
textContainer.ZPosition = 100;
textContainer.BackgroundColor = NSColor.Black.CGColor;
textContainer.BorderColor = NSColor.White.CGColor;
textContainer.BorderWidth = 2;
textContainer.CornerRadius = 15;
textContainer.ShadowOpacity = 0.5f;
View.Layer.AddSublayer(textContainer);
textLayer = new CATextLayer();
textLayer.AnchorPoint = CGPoint.Empty;
textLayer.Position = new CGPoint(10, 6);
textLayer.ZPosition = 100;
textLayer.FontSize = 24;
textLayer.ForegroundColor = NSColor.White.CGColor;
textContainer.AddSublayer(textLayer);
// Rely on setText: to set the above layers' bounds: [self setText:@"Loading..."];
SetText("Loading...", textLayer);
var dirs = NSSearchPath.GetDirectories(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.Local);
foreach (string dir in dirs) {
Console.WriteLine("Dir: {0}", dir);
}
string libDir = dirs[0];
string desktopPicturesDir = Path.Combine(libDir, "Desktop Pictures");
Console.WriteLine("DP Dir: {0}", desktopPicturesDir);
// Launch loading of images on background thread
Task.Run(async () => {
await AddImagesFromFolderUrlAsync(desktopPicturesDir);
});
repositionButton.Layer.ZPosition = 100;
durationTextField.Layer.ZPosition = 100;
lastWindowSize = Window.Frame.Size;
Window.DidResize += (sender, e) => {
if (Math.Abs(lastWindowSize.Width - Window.Frame.Width) > 25 || Math.Abs(lastWindowSize.Height - Window.Frame.Height) > 25) {
windowIsResizing = true;
repositionImages(repositionButton);
lastWindowSize = Window.Frame.Size;
windowIsResizing = false;
}
};
}
示例13: Clone
public override void Clone(CALayer other)
{
RoundProgressLayer o = (RoundProgressLayer) other;
Progress = o.Progress;
StartAngle = o.StartAngle;
TintColor = o.TintColor;
TrackColor = o.TrackColor;
base.Clone (other);
}
示例14: MaskImageWithImage
private void MaskImageWithImage(UIImageView imgView, UIImage maskImage)
{
var aMaskLayer = new CALayer();
aMaskLayer.Frame = new CGRect(0, 0, imgView.Image.Size.Width, imgView.Image.Size.Height);
aMaskLayer.Contents = maskImage.CGImage;
imgView.Layer.Mask = aMaskLayer;
}
示例15: RenderStackedLabelLayer
public static List<IFeature> RenderStackedLabelLayer(IViewport viewport, BasicLayer layer)
{
lock(_syncRoot)
{
var renderedFeatures = new List<IFeature> ();
var canvas = new CALayer ();
canvas.Opacity = (float)layer.Opacity;
//todo: take into account the priority
var features = layer.GetFeaturesInView (viewport.Extent, viewport.Resolution);
var margin = viewport.Resolution * 15;
var clusters = new List<Cluster> ();
//todo: repeat until there are no more merges
ClusterFeatures (clusters, features, margin, null, viewport, viewport.Resolution);
//CenterClusters (clusters);
//CATransaction.Begin();
//CATransaction.SetValueForKey (MonoTouch.Foundation.NSNumber.FromBoolean(true), CATransaction.DisableActionsKey);
foreach(var cluster in clusters){
var feature = cluster.Features.OrderBy(f => f.Geometry.GetBoundingBox().GetCentroid().Y).FirstOrDefault();
//SetFeatureOutline (feature, layer.LayerName, cluster.Features.Count);
//var bb = RenderBox(cluster.Box, viewport);
//Zorg dat dit ALTIJD decimal zelfde ISet als ViewChanged is
//var feature = cluster.Features.FirstOrDefault ();
var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
foreach (var style in styles)
{
if (feature.Styles != null && style.Enabled)
{
var styleKey = layer.LayerName; //feature.GetHashCode ().ToString ();
var renderedGeometry = (feature[styleKey] != null) ? (CALayer)feature[styleKey] : null;
if (renderedGeometry == null) {
renderedGeometry = GeometryRenderer.RenderPoint (feature.Geometry as Mapsui.Geometries.Point, style, viewport);
feature [styleKey] = renderedGeometry;
feature ["first"] = true;
} else {
feature ["first"] = false;
}
}
}
renderedFeatures.Add (feature);
//renderedFeatures.Add (bb);
}
return renderedFeatures;
}
}