今天在网上搜了一下没找到用slider实现等比例缩放的例子
今天自己做了一个大家看下。图片放大缩小,slider往左滑动缩小,slider往右滑动放大
#import "ViewController.h"
@interface ViewController ()
{
UIImageView * _umgView;
UISlider * _sl;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIImage * img = [UIImage imageNamed:@"bg1.jpg"];
_umgView = [[UIImageView alloc]initWithFrame:CGRectZero];
_umgView.image = img;
_umgView.frame = CGRectMake(100, 100, 200, 200);
[self.view addSubview:_umgView];
_sl = [[UISlider alloc]init];
_sl.center = self.view.center;
[self.view addSubview:_sl];
[_sl addTarget:self action:@selector(click) forControlEvents:UIControlEventValueChanged];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)click{
_umgView.transform= CGAffineTransformMakeScale(_sl.value, _sl.value); // 辐射变换
}
@end
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
怎么用UISliader和仿射变换-实现等比例缩放
原文地址:http://blog.csdn.net/zx6268476/article/details/45173689