Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (26 sloc) 765 Bytes
//
// UIImageExtensions.swift
// SnapshotUITestingUITests
//
// Created by Joe Susnick on 1/23/18.
// Copyright © 2018 Joe Susnick. All rights reserved.
//
import UIKit
extension UIImage {
var removingStatusBar: UIImage? {
guard let cgImage = cgImage else {
return nil
}
let yOffset = 22 * scale // status bar height on standard devices (not iPhoneX)
let rect = CGRect(
x: 0,
y: Int(yOffset),
width: cgImage.width,
height: cgImage.height - Int(yOffset)
)
if let croppedCGImage = cgImage.cropping(to: rect) {
return UIImage(cgImage: croppedCGImage, scale: scale, orientation: imageOrientation)
}
return nil
}
}
You can’t perform that action at this time.