CGRect r = CGRectMake(0, image.size.height - 80, image.size.width, 75);

    image = [self drawRectangleOnImage:image rect:r];

    [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];

 

 

//  Converted to Swift 5.3 by Swiftify v5.3.19197 - https://swiftify.com/

let r = CGRect(x: 0, y: image.size.height - 80, width: image.size.width, height: 75)

image = drawRectangle(onImage: image, rect: r)

image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))

 

-(UIImage *)drawRectangleOnImage:(UIImage *)img rect:(CGRect )rect{

    CGSize imgSize = img.size;

    CGFloat scale = 0;

    UIGraphicsBeginImageContextWithOptions(imgSize, NO, scale);

    [img drawAtPoint:CGPointZero];

    [[UIColor whiteColor] setFill];

    UIRectFill(rect);

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return newImage;

}

 

//  Converted to Swift 5.3 by Swiftify v5.3.19197 - https://swiftify.com/

func drawRectangle(on img: UIImage?, rect: CGRect) -> UIImage? {

    let imgSize = img?.size

    let scale: CGFloat = 0

    UIGraphicsBeginImageContextWithOptions(imgSize ?? CGSize.zero, false, scale)

    img?.draw(at: CGPoint.zero)

    UIColor.white.setFill()

    UIRectFill(rect)

    let newImage = UIGraphicsGetImageFromCurrentImageContext()

    UIGraphicsEndImageContext()

    return newImage

}

'진행 프로젝트 > [진행] 개발 팁 "줘볼까?"' 카테고리의 다른 글

pkg mng system. brew -> port  (0) 2020.11.27
#define to let  (0) 2020.11.26
date  (0) 2020.11.25
drawText  (0) 2020.11.24
포로그래메트리  (0) 2020.10.04

+ Recent posts