Type of view

  1. 4 years ago

    Luiz D'Aniello

    16 Apr 2019 User since 2019

    Is there a way to identify the Type of a Subview?

    For example, if i insert a OvalShape into a View, and list all subviews of this View, i will see:

    <UIScroller: 0x7fac04b7fac0; frame = (604 0; 6 576); clipsToBounds = 0; gestureRecognizers = (
    ); layer = <CALayer: 0x600005119b60> >
    <UIScroller: 0x7fac04b24240; frame = (0 570; 610 6); clipsToBounds = 0; gestureRecognizers = (
    ); layer = <CALayer: 0x600005119de0> >
    <CREOOval: 0x7fac02413540; frame = (272 299; 4 4); clipsToBounds = 0; gestureRecognizers = (
    ); layer = <CALayer: 0x600005c27940> >

    How can i get only the type CREOOval?

  2. marco

    16 Apr 2019 Administrator User since 2016

    Hi @Luiz D'Aniello the is operator is what you are looking for:

    var r = View1.subviews;
    for (var view in r) {
    	if (view is OvalShape) {
    		Console.write(view);
    	}
    }
  3. Luiz D'Aniello

    17 Apr 2019 User since 2019

    Yes @marco . Thanks

or Sign Up to reply!