ios – CAEmitterLayer:在CAEmitterCell中使用@ 2x(视网膜)png图像

ios – CAEmitterLayer:在CAEmitterCell中使用@ 2x(视网膜)png图像,第1张

概述使用CAEmitterLayer,@ 2x(视网膜)图像不像iOS中的其他地方那样具有缩放属性.我得到的结果是@ 2x版本的显示尺寸是非视网膜图像的4倍,而不是按比例缩小. 知道怎么解决这个问题吗?我已经尝试在UIImageView中测试图像疼痛,结果是应该的,所以这似乎是CAEmitterLayer和CAEmitterCell的问题.图像具有正确的@ 2x.png说明符. 这是我正在使用的代码: 使用CAEmitterLayer,@ 2x(视网膜)图像不像iOS中的其他地方那样具有缩放属性.我得到的结果是@ 2x版本的显示尺寸是非视网膜图像的4倍,而不是按比例缩小.

知道怎么解决这个问题吗?我已经尝试在UIImageVIEw中测试图像疼痛,结果是应该的,所以这似乎是CAEmitterLayer和CAEmitterCell的问题.图像具有正确的@ 2x.png说明符.

这是我正在使用的代码:

CAEmitterLayer *fallingCoinEmitter = [CAEmitterLayer layer];fallingCoinEmitter.emitter@R_403_4612@ = CGPointMake(self.vIEw.bounds.size.wIDth / 2.0,-30);fallingCoinEmitter.emitterSize = CGSizeMake(self.vIEw.bounds.size.wIDth * 2.0,0.0);;    // Spawn points for the flakes are within on the outline of the linefallingCoinEmitter.emitterMode  = kCAEmitterLayerOutline;fallingCoinEmitter.emitterShape = kCAEmitterLayerline;    // Configure the sNowflake emitter cellCAEmitterCell *coin = [CAEmitterCell emitterCell];coin.birthRate      = 8.0;coin.lifetime       = 5.0;coin.veLocity       = -180;             // falling down slowlycoin.veLocityRange = 80;coin.yacceleration = 40;coin.emissionRange = 0.4 * M_PI;        // some variation in anglecoin.spinRange      = 0.45 * M_PI;      // slow spincoin.contents       = (ID) [[UIImage imagenamed:@"Coin_Generic_Emitter"] CGImage];coin.scale          = 1.0;coin.scaleRange     = 0.0;    // Make the flakes seem inset in the backgroundfallingCoinEmitter.shadowOpacity = 1.0;fallingCoinEmitter.shadowRadius  = 4.0;fallingCoinEmitter.shadowOffset  = CGSizeMake(0.0,3.0);UIcolor *darkGreencolor = [UIcolor colorWithRed:0.005 green:0.163 blue:0.005 Alpha:1.000];fallingCoinEmitter.shadowcolor   = [darkGreencolor CGcolor];[fallingCoinEmitter setContentsScale:[UIScreen mainScreen].scale];//fallingCoinEmitter.shouldRasterize = YES;//[fallingCoinEmitter setRasterizationScale:[UIScreen mainScreen].scale];//fallingCoinEmitter.scale = fallingCoinEmitter.scale / [[UIScreen mainScreen] scale];    // Add everything to our backing layer below the UIContol defined in the storyboardfallingCoinEmitter.emitterCells = [NSArray arrayWithObject:coin];[self.vIEw.layer insertSublayer:fallingCoinEmitter atIndex:0];

谢谢!

更新:

@Fabian,设置contentScale不起作用,至少不是我的解决方案

[fallingCoinEmitter setContentsScale:[UIScreen mainScreen].scale];

我也尝试了这个没有结果..

emitter.shouldRasterize = YES;    [emitter setRasterizationScale:[UIScreen mainScreen].scale];

并且设置比例范围不起作用. iPad 2和3(w RD)的尺寸仍然存在差异.

解决方法 您应该尝试根据设备的屏幕修改CAemmitterCells的scale和scaleRange属性.

cell.scale = cell.scale / [[UIScreen mainScreen] scale];

总结

以上是内存溢出为你收集整理的ios – CAEmitterLayer:在CAEmitterCell中使用@ 2x(视网膜)png图像全部内容,希望文章能够帮你解决ios – CAEmitterLayer:在CAEmitterCell中使用@ 2x(视网膜)png图像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1020179.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存