Prob when rotating an uiimageview - ios

When I am working with uiimageview, I want to rotate it with a small angle, and I did. But, in the border of uiimageview after rotating appears spikes, like a saw. I do not know why and try to fix it but I cant. Please help me.

Couple of options..
1) If you are using Core Graphics functions to rotate you can enable anti alias options
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
2) Add a 1 pixel transparent border to the your image on all 4 sides.
One more thing, there is a technical term to the spikes you saw and it is aliasing. And the techniques to prevent aliasing are called anti aliasing techniques. Hope this helps.

Thanks all you guys :) My friend showed me another way to fix it. I think this way is better than using transparent border trick. He changed an attribute in info plist file, that is "Renders with edge antialisasing", to YES. And everything becomes okay :). I hope it will help someone get a same prob with me :)

Take a UIView as subView and Place UIImageView on subView.
Keep the size of subView and UIImageView Same.
Now, Use "UIViewAnimationTransitionFlipFromRight" or "UIViewAnimationTransitionFlipFromLeft" with Timer.

What you can do easily is to add a 1px transparent border around your image. So if your image is, let's say, 50x50 pixels you need to make it 52x52 such that the outer pixels are transparent. When you will rotate it should look fine now.

Related

PaintCode, How to add a frame around a portion of a vector and have it dynamically resize?

I've imported a vector layer from a psd into paint code v1, I'm trying to create a background image and make it universal.
I can't seem to add a frame around the vector, to complicate matters, I only need a portion, the center, of the layer. (The design is based around a circle, it has lines drawn towards the center of the circle.)
I can’t seem to add a frame to dynamically resize the part I need.
I found this http://www.raywenderlich.com/36341/paintcode-tutorial-dynamic-buttons the part about frame ans groups doesn't help me....
When I add a click frame and drag it around the area I need, it's at the same level as the vector layer. I've also tried adding a group around both, but that doesn't seem to obey the frame size either.
I’ve looked through the tutorials and googled adding a frame, but I can’t seem to achieve what I need.
EDIT
A frame is supposed to be at the same level as the vectors you're working with.
All you do then is set the resize rules of your vectors. There is a little rectangle in the frame's parameters interface with straight arrows and springs that you can modify to fit your wishes.
I think I also remember a checkbox setting to resize only what's inside the frame.
Now I haven't used PaintCode for a while, but if this doesn't help you, there probably is a problem with your vector layer.
I don't know if this information helps.
But if you resizing doesn't work as you expected. Look carefully at the transformation box (the one with the springs attached). When you have put a frame around your object. The middle dot in this box should be blue instead of green. if t's green, you may have a problem with the originating point of your objects and then the resizing may not work as you expected.

Center-aligned masked UIImageView / Imitating Twitter & Facebook app's image views

Post title can be a little bit weird but here's what I'm looking forward to do:
Look at the image in the middle, it's displaying only a part of the original image. It's still high definition, not really cropped but only masked with the center of the image at the center of the view.
So basically they put a bigger image behind a smaller view (I did that for having circular imageviews in the past). But how can I achieve that particularly?
Is there any cocoapods or something to do so or should I get started doing it myself? Any suggestions on how to code-wisely build this?
The main goal here is to keep a static space to display images so they're always the same width/height. Doing this effect seems like a good way of achieving this.
EDIT: Here's a little sketch of an idea I just had to mimic that behavior:
Thanks a lot and have a nice day.
If you're asking what I think you're asking, you don't have to look far to find this functionality. Use UIView's built in contentMode property, specifically in this case, UIViewContentModeScaleAspectFill.
[imageView setContentMode:UIViewContentModeScaleAspectFill];
Then to crop of the parts of the image extending out of the frame, be sure to use clipsToBounds:
[imageView setClipsToBounds:YES];
Here is another solution, but make sure your image width and height is greater than the imageview,
imageView.contentMode=UIViewContentModeCenter;
imageView.clipsToBounds=YES;
imageView.clearsContextBeforeDrawing=NO;

How do I achieve Yahoo Weather ScrollView Effect?

I'm really interested in creating a UIScrollView similar to the Yahoo Weather app. Here's an example on video:
http://www.youtube.com/watch?v=a-q_yetkpik
I have found this Git which will alow me to do the fade background thing:
https://github.com/justinmfischer/core-background
But how would I achieve the blur effect at the top so that as content scrolls up, it almost fades out behind the UINavigationBar
Any help would be appreciated!!
I wrote the code for the UI effects in the Yahoo! Weather app, would be happy to answer your question.
Sounds like you've figured out how to do the blur (fade between a blurred image based on pixel offset, maxing out at a certain amount... for even better effect, you can have multiple steps in the blur - i.e. fade between non-blurred to half-blurred, then half-blurred to full-blurred etc).
For the fading under kind of effect, you can set the mask property on your content view's layer:
https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/mask
The mask is an image that fades from transparent to opaque.
--Iain.
I am probably a little late for the party but I have an example project that does exactly that. I did try to look through Yahoo! app for the said image mask Iain was talking about. I have yet to be able to use it the way he described. So I created a CALayer on the fly to achieve the effect.
(#Iain, awesome job! big fan)
Here is the GitHub link
I haven't personally tried it but this might be a good start: https://github.com/kronik/DKLiveBlur
DKLiveBlur
Sources of DKLiveBlur and Demo app to show live blur effect similar to yahoo weather iOS app.
I achieved a similar effect using FXBlurView:
https://github.com/nicklockwood/FXBlurView
You simply set the blurRadius relative to the amount scrolled: scrollView.contentOffset.y
Thanks to Iain for pointing out CALayer masks.
Download the sample code for blur from Evan Davis blog.

iPhone App Brush effects (Based on GLPaint) [duplicate]

I am working on a drawing application based on GLPaint code. Do somebody know how to get an effect like this ? I have tried with different values for the width and the Height for the brush, but still it remains same .
Do i need to consider glBlendFunc() ? or Is it achievable thorough changing the width and the heigh of the brush.
Thanks in advance.
The easiest way to achieve that type of effect is to reducing the alpha from 1.0 to 0.7.
In PaintingView Change Brush Height and Width as shown in following image...And One more thing is that change brush image according to your requirements for more color custom effect..
Hope, this will help you..

How to select a triangle in XNA?

I have a triangle with a transparent background (png image) I want its color to change when selecting it.
The point is that the color should change only when touching the non-transparent part of the image.
This should be working when the image is scaled..
Any ideas please?
Thanks...
Since you do not know the exact size/shape of the triangle, you'll need to use Per-Pixel collision detection. The App Hub has a tutorial for that. It even works with scaled/rotated objects.
Hope it helps!

Resources