Avoid generating zero size bitmaps
This commit is contained in:
@@ -31,8 +31,9 @@ class GradientView: UIImageView
|
||||
}
|
||||
|
||||
private func gradientImage(forSize size: CGSize) -> UIImage? {
|
||||
var image: UIImage? = nil
|
||||
guard size != .zero else { return nil }
|
||||
|
||||
var image: UIImage? = nil
|
||||
UIGraphicsBeginImageContext(size)
|
||||
if let context = UIGraphicsGetCurrentContext() {
|
||||
let gradientColorsArray = self.colors.map { $0.cgColor }
|
||||
|
||||
@@ -281,8 +281,9 @@ class URLBar: ReliefButton
|
||||
}
|
||||
|
||||
private func fadeBackgroundImageForSize(_ size: CGSize, cutoffLocation: CGFloat) -> UIImage? {
|
||||
var image: UIImage? = nil
|
||||
guard size != .zero else { return nil }
|
||||
|
||||
var image: UIImage? = nil
|
||||
UIGraphicsBeginImageContext(CGSize(width: size.width, height: 1.0))
|
||||
if let context = UIGraphicsGetCurrentContext() {
|
||||
let gradientColorsArray = [
|
||||
|
||||
@@ -77,6 +77,10 @@ static CGFloat RoundToScale(CGFloat v, CGFloat s) {
|
||||
+ (UIImage *)iconRepresentationForPolicyType:(SBRScriptOriginPolicyType)policyType withConfiguration:(nonnull SBRScriptPolicyIconConfiguration *)configuration
|
||||
{
|
||||
const CGSize size = [configuration size];
|
||||
if (CGSizeEqualToSize(size, CGSizeZero)) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
UIFont *font = [UIFont boldSystemFontOfSize:size.height - 2];
|
||||
NSDictionary<NSAttributedStringKey, id> *attrs = @{
|
||||
NSFontAttributeName : font,
|
||||
|
||||
Reference in New Issue
Block a user