1

i have added a UIView on the View Controller.Initially i set the border color on the UIView now it looks view border smoothly.But while scaling that View through Gesture recognizer the border color would be pixelated .

initial code below here

- (id)initWithImage:(UIImage*)image delegate:(id)delegat{
    if ( (self = [super initWithImage:image]) ) {
        self.layer.masksToBounds = YES;
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width+1, self.frame.size.height+1);
        self.contentMode = UIViewContentModeCenter;
        ratio = image.size.height / image.size.width;
        itemType = 2;
        self.userInteractionEnabled =TRUE;
        self.delegate = delegat;
        self.layer.borderColor = [UIColor redColor].CGColor;
        self.layer.borderWidth = 4;
        scaleFactor = 1.0;
        rotateAngle = 0.0;
        fontSize = 22;
        self.contentScaleFactor = 1.0;
        if(image != nil){
            frameWidth = image.size.width;
            frameHeight = image.size.height;
        }else{
            frameWidth = self.frame.size.width;
            frameHeight = self.frame.size.height;    
        }

        [self addGestureRecognizers];
    }    
    return self;
}

enter image description here

here is code for rotate code

- (void)rotatePiece:(UIRotationGestureRecognizer *)gestureRecognizer{


    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
        // To undo the action : store information
        [[UIAppDelegate viewController] storeAction:CHUndoActionTypeRotate item:self];

        [gestureRecognizer view].transform = CGAffineTransformRotate([[gestureRecognizer view] transform], [gestureRecognizer rotation]);
        [gestureRecognizer setRotation:0];
    }

}

this is what i got while rotate the view

enter image description here

STW
  • 44,917
  • 17
  • 105
  • 161
StalinPusparaj
  • 53
  • 2
  • 11

1 Answers1

1

This is a seemingly pretty common issue. What you want is for the borders to be anti-aliased. Here is one post with a solution and here is another.

Basically you could use a UIImageView and add a one pixel transparent border around the image, so that the actual border would be anti-aliased.

Community
  • 1
  • 1
Dima
  • 23,484
  • 6
  • 56
  • 83
  • i am using jpeg image so how should i do the border to be antialiased. i am using UIView not UIImageView. how should i add a one pixel transparent border in the UIView. – StalinPusparaj Jul 05 '12 at 10:34