*   >> Læs Uddannelse artikler >> science >> programming

iPhone Ændre størrelse på en UIImage

ppen, ImageView, buttonImage, imageViewImage, selectingButtonImage, selectingImageViewImage;

//Implement viewDidLoad at gøre yderligere opsætning efter indlæsning udsigten, typisk fra en spids

- (void) viewDidLoad {

[superviewDidLoad].

selectingButtonImage = NO ;

selectingImageViewImage = NEJ,

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) animated {

[superviewWillAppear: animerede];

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] init]

imagePicker.delegate = selv,

selectingButtonImage = JA ;

[selfpresentModalViewController: imagePicker animeret: YES];

[imagePicker frigivelse]

}

- (IBAction) selectImageViewImage {

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

imagePicker.

delegate = selv,

selectingImageViewImage = JA,

[selfpresentModalViewController: imagePicker animeret: YES];

[imagePicker frigivelse]

}

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

[selfdismissModalViewControllerAnimated: YES];

}

- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingImage: (UIImage *) selectedImage editingInfo: (NSDictionary *) editingInfo {

if (selectingButtonImage) {

CGSize size = selectedImage.

size;

CGFloat forhold = 0;

if (size.width> size.height) {

forhold = 128,0 /størrelse .width,

} else {

forhold = 130,0 /size.height;

}

CGRect rect = CGRectMake (0,0, 0,0, forholdet * size.width, forholdet * size.height)

UIGraphicsBeginImageContext (rect.size)

[selectedImage drawInRect: rec

Page   <<  [1] [2] [3] [4] >>
Copyright © 2008 - 2016 Læs Uddannelse artikler,https://uddannelse.nmjjxx.com All rights reserved.