How do I create a CGRect from a CGPoint and CGSize?

后端 未结 4 441
攒了一身酷
攒了一身酷 2021-02-01 01:22

I need to create a frame for a UIImageView from a varying collection of CGSize and CGPoint, both values will always be different depending

4条回答
  •  时光说笑
    2021-02-01 01:48

    Two different options for Objective-C:

    CGRect aRect = CGRectMake(aPoint.x, aPoint.y, aSize.width, aSize.height);
    
    CGRect aRect = { aPoint, aSize };
    

    Swift 3:

    let aRect = CGRect(origin: aPoint, size: aSize)
    

提交回复
热议问题