0
votes

I am easily rotating my UIView using CATransform3DMakeRotation but the problem is occurring when em adding a SubView after the rotation. It is adding it as rotated..

This is my view before the rotation

enter image description here

This is how i am rotating my UIView

    aCustomView.layer.transform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0);

and after that em adding a custom Badge on it by this

    JSCustomBadge *onlineUsersCountBadge = [JSCustomBadge customBadgeWithString:@"1"];

    CGSize size = onlineUsersCountBadge.frame.size;
    onlineUsersCountBadge.frame = CGRectMake(imageViewRect.origin.x+20, imageViewRect.size.height*0.3, size.width, size.height);
    [aCustomView addSubview:onlineUsersCountBadge];

This is my view after rotation and added Subview

enter image description here

1

1 Answers

2
votes

If I understood it well, you want the view to rotate but the badge to stay normal.

In my opinion, the best approach to this problem is to create an invisible subview containing all the elements (UIViews) you want to rotate (such as the background image). You then shouldn't apply the rotation to the full view, but only to that subview. Doing so, if you want to add an element which shouldn't be rotated, such as your badge, you add it to the main non-rotated view and not to the rotated subview.

Hope it helps!