CALayer *sublayer = [CALayer layer]; /*sublayer.backgroundColor = [UIColor blueColor].CGColor; sublayer.shadowOffset = CGSizeMake(0, 3); sublayer.shadowRadius = 5.0;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(400, 400), NO, 1);
Setting this argument to NO solves my problem.