首页 > 代码库 > 视图缩放、移动、旋转--ios
视图缩放、移动、旋转--ios
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; view.backgroundColor=[UIColor redColor]; view.tag=10; [self.window addSubview:view]; UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame=CGRectMake(200, 200, 50, 50); [button setTitle:@"改变" forState:UIControlStateNormal]; [button addTarget:self action:@selector(changeViewScale) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:button]; UIButton *translateButton=[UIButton buttonWithType:UIButtonTypeSystem]; translateButton.frame=CGRectMake(50,200, 50, 50); [translateButton setTitle:@"移动" forState:UIControlStateNormal]; [translateButton addTarget:self action:@selector(changeViewTransalte) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:translateButton]; UIButton *rotateButton=[UIButton buttonWithType:UIButtonTypeRoundedRect]; rotateButton.frame=CGRectMake(100, 200, 50, 50); [rotateButton setTitle:@"旋转" forState:UIControlStateNormal]; [rotateButton addTarget:self action:@selector(changeViewRotate) forControlEvents:UIControlEventTouchUpInside]; [self.window addSubview:rotateButton]; [self.window makeKeyAndVisible];
-(void) changeViewScale{ UIView *view =[self.window viewWithTag:10]; view.transform=CGAffineTransformScale(view.transform, 0.8, 0.8);}-(void) changeViewTransalte{ UIView *view=[self.window viewWithTag:10]; view.transform=CGAffineTransformTranslate(view.transform, 10,0);}-(void) changeViewRotate{ UIView *view=[self.window viewWithTag:10]; view.transform=CGAffineTransformRotate(view.transform, 0.33);}
视图缩放、移动、旋转--ios
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。