This is not a question but a solution.
If you use backgroundImage on iPhone and you have both normal and @2x images to display you can fix the double size image problem by changing lines around 426 (where you see the TiDimensionLayerContentCenter call) in file TiUIView.m with the following content:
CGRect cc = TiDimensionLayerContentCenter(topCap, leftCap, topCap, leftCap, [resultImage size]); self.layer.contentsCenter = cc; CGFloat scale = [UIScreen mainScreen].scale; self.layer.contentsScale = scale;Yes, this is a format that is easy to debug just in case. The point is the self.layer.contentsScale call which is missing from the Ti code and this causes the @2x bug.
Obviously the best if you change the file at its original location somewhere inside your Ti install. On Mac this is: "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/Classes/TiUIView.m".
4 Answers
Thanks a lot! This saves me a lot of headache.
I wonder why Appcelerator is not solving this bug. In SDK 1.75 the last lines are still missing.
Sorry, I am totally ignorant about this and would like to fix this issue. I am using 1.8.2 and it still seems to be a problem with top and left caps. This is the code that I have, in the file that you mentioned. What would the new one look like?
Thanks for your help.
-(void)setBackgroundImage_:(id)image { UIImage* bgImage = [TiUtils loadBackgroundImage:image forProxy:proxy]; if (backgroundRepeat) { [self renderRepeatedBackground:bgImage]; } else { [self backgroundImageLayer].contents = (id)bgImage.CGImage; if (bgImage != nil) { [self backgroundImageLayer].contentsCenter = TiDimensionLayerContentCenter(topCap, leftCap, topCap, leftCap, [bgImage size]); } } self.clipsToBounds = bgImage!=nil; self.backgroundImage = bgImage; }
Thanks a lot! This saves me a lot of headache.
I wonder why Appcelerator is not solving this bug. In SDK 1.75 the last lines are still missing.
Hello, this is working fine for me with sdk 2.1.0+ but I noted an horizontal black line of 1px between the images repeat.
My image is correct, so I think the problem is related to the repeat function.
Anyone experienced this problem too?
Thank you, Stefano.
Your Answer
Think you can help? Login to answer this question!