Objective-C: una alternativa a la utilización de CGRectMake

Lunes, 27 de julio 2009

CGRectMake() es una función (en realidad una línea # define) utiliza mucho, especialmente cuando se crea objetos de código o la interfaz gráfica de usuario. Su uso es por lo tanto a menudo vinculados componentes de inicialización UIKit sino también a UIView simple o UIImageView CGRectMake() devuelve una struct (tipo de estructura) CGRect

Objective-C:
  1. struct (CGRect
  2. Origen CGPoint;
  3. Tamaño CGSize;
  4. );
  5. typedef struct CGRect CGRect;

Que a su vez se compone de dos diferentes struct CGPoint y CGSize

Objective-C:
  1. struct (CGPoint
  2. CGFloat x;
  3. Y CGFloat;
  4. );
  5. typedef struct CGPoint CGPoint;
  6. Tallas * /. * /
  7. struct (CGSize
  8. Ancho CGFloat;
  9. Altura CGFloat;
  10. );
  11. typedef struct CGSize CGSize;

Eso, a su vez, aún contienen los tipos CGFloat o float Si analizamos el código de CGRectMake () son:

Objective-C:
  1. CG_INLINE CGRect
  2. CGRectMake (CGFloat x, y CGFloat, CGFloat anchura, altura CGFloat)
  3. (
  4. Rect CGRect;
  5. y; = x rect.origin.x; rect.origin.y = y;
  6. height; width = rect.size.width; rect.size.height = altura;
  7. rect retorno;
  8. )

De ello se deduce, por tanto, que esta parte de código:

Objective-C:
  1. UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton * gbutton = [buttonWithType UIButton: UIButtonTypeRoundedRect];
  2. 12,409,100,40 ) ; gbutton.frame = CGRectMake (12,409,100,40);
  3. @ "Press" forState : UIControlStateNormal ] ; [SetTitle Gbutton: @ "Prensa" Forst: UIControlStateNormal];
  4. gbutton ] ; [AddSubview MainWindow: gbutton];

Con razón se puede escribir como:

Objective-C:
  1. UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton * gbutton = [buttonWithType UIButton: UIButtonTypeRoundedRect];
  2. 12,409,100,40 } ; = gbutton.frame (CGRect) (12,409,100,40);
  3. @ "Press" forState : UIControlStateNormal ] ; [SetTitle Gbutton: @ "Prensa" Forst: UIControlStateNormal];
  4. gbutton ] ; [AddSubview MainWindow: gbutton];

Sólo para acelerar la ejecución de código un poco '... :)

Post relacionados

Fue útil esta información?: Per nientePocoAbbastanzaMoltoMoltissimo
Loading ... Cargando ...

2 comentarios a "Objective-C: una alternativa a la utilización de CGRectMake"

  1. getAvatar 1,0
    27 de julio 2009 Cristian:

    La curiosidad ": si quieres aprender Obj-C, por ejemplo, a partir de cero o casi, en que las publicaciones que no puedes pagar?

  2. getAvatar 1,0
    01 ago, 2009 Giovambattista Fazioli:

    @ Cristian: Google Book Search (Google Books), hay muchos recursos (en Inglés) es prácticamente completa.

Deja tu comentario

TAG XHTML RESTRICCIONES: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> código de inserción:
 <pre></pre>         // blocco generico [code][/code]       // blocco generico [as][/as]           // Actionscript [css][/css]         // CSS Style Sheet [html][/html]       // HTML [js][/js]           // Javascript [objc][/objc]       // Objective-C [php][/php]         // PHP [sql][/sql]         // SQL