Search code examples
iosswiftcgfloat

How to stretch an object?


I have a UIMapView and a small area for banner ads. I want to stretch the UIMapView 50 pixels when ads are removed.

I tried the following line but I couldn't convert CGFloat to float value.

mapView.frame = CGRectMake(mapView.origin.x, mapView.origin.y, mapView.frame.width, (Float(mapView.frame.height)+50))

enter image description here enter image description here


Solution

  • Run this code and it will work for you:

    self.map.frame = CGRect(x: map.frame.origin.x, y: map.frame.origin.y, width: map.frame.width, height: map.frame.height + 50)