*   >> Leitura Educação Artigos >> science >> programação

iPhone redimensionar uma UIImage

otãosynthesize, imageView, buttonImage, imageViewImage, selectingButtonImage, selectingImageViewImage;

//Implementar viewDidLoad fazer a configuração adicional depois de carregar a vista, normalmente a partir de um bico

- (void) viewDidLoad {

[superviewDidLoad];.

selectingButtonImage = NO ;

selectingImageViewImage = NO;

UIImage * scaledButtonImage = [buttonImagescaleToSize: CGSizeMake (120.0f, 120.0f)];

UIImage * scaledImageViewImage = [imageViewImagescaleToSize: CGSizeMake (100,0 f, 100.

0f)];

[buttonsetImage: scaledButtonImage forState: UIControlStateNormal];

[imageViewsetImage: scaledImageViewImage];

}

- (void ) viewWillAppear: (BOOL) animado {

[superviewWillAppear: animação];

UIImage * scaledButtonImage = [buttonImagescaleToSize: CGSizeMake (120.0f, 120.0f)];

UIImage * scaledImageViewImage = [imageViewImagescaleToSize: CGSizeMake (100.0f, 100.

0f)];

[buttonsetImage: scaledButtonImage forState: UIControlStateNormal];

[imageViewsetImage: scaledImageViewImage];

}

- (IBAction) photoButtonPressed {

UIImagePickerController * imagePicker = [[UIImagePickerControlleralloc] o init];

imagePicker.delegate = auto;

selectingButtonImage = YES ;

[selfpresentModalViewController: imagePicker animado: YES];

[liberação imagePicker];

}

- (IBAction) selectImageViewImage {

< p> UIImagePickerController * imagePicker = [[UIImagePickerControlleralloc] o init];

imagePicker.

delegate = auto;

selectingImageViewImage = YES;

[selfpresentModalViewController: imagePicker animado: YES];

[liberação imagePicker];

}

- (void) imagePickerControllerDidCancel: (UIImagePickerController *) selecionador {

[selfdismissModalViewControllerAnimated: YES];

}

- (void) imagePickerController: (UIImagePickerController *) selecionador didFinishPickingImage: (UIImage *) SelectedImage editingInfo: (NSDictionary *) editingInfo {

if (selectingButtonImage) {

CGSize size = selectedImage.

size;

CGFloat ratio = 0;

if (size.width> size.height) {

ratio = 128,0 /tamanho .width;

} else {

ratio = 130,0 /size.height;

}

CGRect rect = CGRectMake (0.0, 0.0, razão * size.width, razão * size.height);

UIGraphicsBeginImageContext (rect.size);

Page   <<  [1] [2] [3] [4] >>
Copyright © 2008 - 2016 Leitura Educação Artigos,https://artigos.nmjjxx.com All rights reserved.