Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ - (WXDisplayBlock)_displayBlock

__strong WXComponent* sself = wself;
if (sself) {
CGFloat width = bounds.size.width ?: 1;
CGFloat height = bounds.size.height ?: 1;
CGSize size = CGSizeMake(width, height);
UIGraphicsBeginImageContextWithOptions(bounds.size, [sself _bitmapOpaqueWithSize:bounds.size] , 0.0);
UIImage *image = [sself drawRect:bounds];
if (!image) {
Expand Down Expand Up @@ -259,7 +262,10 @@ - (void)triggerDisplay

- (CGContextRef)beginDrawContext:(CGRect)bounds
{
UIGraphicsBeginImageContextWithOptions(bounds.size, [self _bitmapOpaqueWithSize:bounds.size], 0.0);
CGFloat width = bounds.size.width ?: 1;
CGFloat height = bounds.size.height ?: 1;
CGSize size = CGSizeMake(width, height);
UIGraphicsBeginImageContextWithOptions(size, [self _bitmapOpaqueWithSize:size], 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();

// float scaleFactor = [[UIScreen mainScreen] scale];
Expand Down
5 changes: 4 additions & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,10 @@ - (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes

- (UIImage *)imageFromLayer:(CALayer *)layer
{
UIGraphicsBeginImageContextWithOptions(layer.frame.size, NO, 0);
CGFloat width = layer.frame.size.width ?: 1;
CGFloat height = layer.frame.size.height ?: 1;
CGSize size = CGSizeMake(width, height);
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
[layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Expand Down