Rory McCrossan Rory McCrossan - 27 days ago 5
Objective-C Question

Equivalent of CGRectInfinite & CGRectIsInfinite in MonoTouch/Xamarin

I am trying to convert an open source flyout menu from Objective-C to Xamarin. The current issue I have is that the Obj-C code creates a frame using

CGRectInfinite
. This does not appear to be available under MonoTouch, via the usual
RectangleF
class. Is there an alternative?

Similarly, there does not appear to be a
CGRectIsInfinite
equivalent in
RectangleF
. What, if any, is the alternative?

Answer

Add this using statement first:

using MonoTouch.CoreGraphics;

Then you can test it with this:

public static RectangleF GetInfinite()
{
    var image = CIImage.EmptyImage;

    if (image.Extent.IsInfinite ())
    {
        return image.Extent;
    }

    throw new Exception ("Unable to create infinite rect");
}
Comments