, sono molto utilizzati nello sviluppo di applicazioni per Apple iPhone. El objeto de UIImage , junto con UIImageView , son ampliamente utilizados en el desarrollo de aplicaciones para el iPhone de Apple. Aquí hay un código útil fragmento-hacer una serie de procesos comunes:
La combinación de dos (o más) imágenes
1 2 3 4 5 6 7 8 9 10 11 12
| UIImage * ) combineImage : ( UIImage * ) imageA imageB : ( UIImage * ) imageB { - (UIImage *) combineImage: (UIImage *) Imageo imageB: (UIImage *) {imageB ; UIGraphicsBeginImageContext (imageA.size);
CGRectMake ( 0 , 0 , imageA.size.width, imageA.size.height ) ] ; [Imageo drawInRect: CGRectMake (0, 0, imageA.size.width, imageA.size.height)]; CGRectMake ( 0 , 0 , imageB.size.width, imageB.size.height ) ] ; [ImageB drawInRect: CGRectMake (0, 0, imageB.size.width, imageB.size.height)];
UIGraphicsGetImageFromCurrentImageContext ( ) ; UIImage * combinatedImage UIGraphicsGetImageFromCurrentImageContext = ();
UIGraphicsEndImageContext ();
combinatedImage retorno; } |
Continuación ...
CGRectMake() es una función (en realidad una línea # define) que se utiliza mucho, especialmente cuando se crea objetos gráficos de código o interfaz de usuario. o UIImageView . CGRectMake() restituisce una struct (struttura di tipo) CGRect : Su uso se asocia a menudo por lo tanto, los componentes de la inicialización de UIKit , sino también a simples UIView o UIImageView . CGRectMake() devuelve una struct (tipo de estructura) CGRect :
1 2 3 4 5
| struct {CGRect CGPoint origen; CGSize tamaño; }; typedef struct CGRect CGRect; |
: Que a su vez se compone de dos diferentes struct CGPoint y CGSize :
1 2 3 4 5 6 7 8 9 10 11 12 13
| struct {CGPoint CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint;
Tamaños / *. * /
struct {CGSize Ancho CGFloat; CGFloat altura; }; typedef struct CGSize CGSize; |
. Que, a su vez, otra vez, contienen tipos CGFloat o el tipo float . Si analizamos el código de CGRectMake () son los siguientes:
1 2 3 4 5 6 7 8
| CG_INLINE CGRect CGRectMake (CGFloat x, y CGFloat, ancho CGFloat, CGFloat altura) { CGRect rect; y; rect.origin.x = x, y = rect.origin.y; height; rect.size.width = anchura, altura = rect.size.height; volver rect; } |
De ello se desprende, por tanto, que este pedazo de código:
1 2 3 4
| [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton gbutton * = [UIButton buttonWithType: UIButtonTypeRoundedRect]; 12 , 409 , 100 , 40 ) ; gbutton.frame CGRectMake = (12, 409, 100, 40); @ "Press" forState : UIControlStateNormal ] ; [Gbutton setTitle: @ "Prensa" Forst: UIControlStateNormal]; gbutton ] ; [MainWindow addSubview: gbutton]; |
Con razón se puede escribir como:
1 2 3 4
| [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton gbutton * = [UIButton buttonWithType: UIButtonTypeRoundedRect]; CGRect ) { 12 , 409 , 100 , 40 } ; gbutton.frame = (CGRect) {12, 409, 100, 40}; @ "Press" forState : UIControlStateNormal ] ; [Gbutton setTitle: @ "Prensa" Forst: UIControlStateNormal]; gbutton ] ; [MainWindow addSubview: gbutton]; |
Sólo para acelerar las cosas "se ejecuta el código ... 
Continuación ...
Últimos Comentarios
Simon : Se molesta perturbado de nuevo y utilizar ese espacio para estas cosas ... sin embargo, no funciona ...
Giovambattista Fazioli : @ Simon: ¿qué puede ser debido a la sintaxis que utiliza, específicamente para PHP 5 +,...
Simon : He probado la noche anterior poner todo en functions.php, formas bien, jQuery, y las fichas que jQueryUI ...
Giovambattista Fazioli : @ Simon: Yo recomiendo la limpieza de ingresar un código como el de ...
Simon : @ Giovambattista Fazioli: Gracias por su paciencia, todo está claro ... ahora me siento ahora, ...