如何缩放所选图像iPhone sdk?

时间:2011-12-05 06:36:21

标签: iphone objective-c

假设我从图像选择器中选择了图像,现在我想缩放该图像,并希望在按钮或任何图像视图中设置该缩放图像。

3 个答案:

答案 0 :(得分:0)

您是否看过contentMode的{​​{1}}属性。

UIImageView

答案 1 :(得分:0)

当您从选择器中选择图像时,它应返回UIImage类型。只需将其设置为任何UIView子类的图像(按钮也是UIView子类):

[yourUIImageView setImage:UIImageFronUIPicker];
[yourUIButton setBackgroundImage:UIImageFronUIPicker];

依旧......

答案 2 :(得分:0)

在视图控制器中实现UIImagePickerControllerDelegate并实现下面的委托方法

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

    [selectedImageBtn setImage:image forState:UIControlStateNormal];
    [[imagePicker parentViewController] dismissModalViewControllerAnimated:YES];

}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [[imagePicker parentViewController] dismissModalViewControllerAnimated:YES];
}