UIKit.UIView.Frame Property
Coordinates of the view relative to its container.


[get: Foundation.Export("frame")]
[set: Foundation.Export("setFrame:")]
public virtual CoreGraphics.CGRect Frame { get; set; }


The value of this property is in points, not pixels.


The UIView.Frame property is expressed in terms of the UIView.Superview's coordinate system. (The UIView.Bounds property is expressed in terms of this UIKit.UIView's coordinate system.)

The following example shows just one way the UIView.Frame's coordinate system and values can vary from that of the UIKit.UIView's UIView.Bounds. In this case, a UIKit.UIImageView is placed with an initial UIView.Frame originating at {100,100} and of size {100,100}. Once rotated, both the origin and size of the UIView.Frame bounding box shift: the origin to accomodate the rotation and the sizes in order to contain the diagonal of the {100,100} box. The UIView.Bounds of the flowerView remains [{0,0},{100,100}].

C# Example

var flowerView = new UIImageView(new RectangleF(100, 100, 100, 100)) {
	Image = UIImage.FromFile("flower.png"),
	ContentMode = UIViewContentMode.Center,
	ClipsToBounds = true

flowerView.Transform = CGAffineTransform.MakeRotation((float) Math.PI / 4);

When changes are done to this property, the UIView.Center is updated with the new location and the UIView.Bounds is updated with the new dimensions and a re-layout of the subviews is performed.

Changing this property will not trigger a call to UIView.Draw(System.Drawing.CoreGraphics.CGRect) unless you set the UIView.ContentMode property to UIViewContentMode.Redraw.

At least on iOS 6 and later, changing this property causes the a re-layout of the subviews, even if the dimensions are the same. This can cause performance problems as some views (like UITableView) can perform some very expensive computations when they are laid out.

If your UIView.ContentMode property is set to UIViewContentMode.Redraw, you can avoid a redraw of your view if you update the UIView.Center property instead of updating the Frame as that one will merely move the view without triggering a call to UIView.LayoutSubviews().

This property participates in the implicit animation protocol, changing it outside of a transaction will trigger an implicit animation for its values.

If you change the UIView.Transform property to a matrix that does not represent the identity matrix, changing this property can have unintended consequences. In those cases, you should instead update UIView.Center and UIView.Bounds directly.


Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: