UIView翻转和缩放

1. 在UIView中,将该view使用到的坐标进行旋转,这样当该view addSubview时,会使用坐标方向来进行:



@implementation PoseDetailContentView

- (id)initWithFrame:(CGRect)frame 

{

    if (self = [super initWithFrame:frame]) 

{

            // Imp ortant here, rotate THIS UIView

            [self setCenter: CGPointMake(160.0f, 240.0f)];

            [self setTransform: CGAffineTransformMakeRotation(degreesToRadian(90))];



2. 

该view中的其他子视图使用原计划的坐标,添加到横屏中即可.



补充:

下面的代码,可以让UIView即旋转,又缩放.




        CGAffineTransform transform = CGAffineTransformMakeRotation(degreesToRadian(60));

        transform = CGAffineTransformScale(transform, 0.5, 0.5);

        

        [self setTransform: transform];    // this effects the SUBVIEWS rotate and scale





--------------------------------------------------------------------------------------------------
- (void)applicationDidFinishLaunching:(UIApplication *)application {    
 
    // Override point for customization after application launch
    [window makeKeyAndVisible];
    UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(window.frame.size.width/2-50.0, window.frame.size.height/2-50.0, 100.0, 100.0)];
    myImageView.image = [UIImage imageNamed:@"bmw.jpg"];
    [UIImageView beginAnimations:nil context:nil];
    [UIImageView setAnimationDuration:3.0];
    [myImageView setTransform:CGAffineTransformMakeRotation(10.0)];
    [UIImageView commitAnimations];
 
    [window addSubview:myImageView];
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值