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