The following code works perfectly on iOS 7.1
UIView *superView = self.superview;
[self removeFromSuperview];
CGFloat rightMarginWidth = self.rightMarginWidth ? self.rightMarginWidth : defaultRightMarginWidth;
CGRect newFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width + rightMarginWidth, self.frame.size.height);
//assign a new frame
self.frame = newFrame;
[superView addSubview:self];
However, on iOS 8.0, suppose newFrame is origin=(x=30, y=29) size=(width=127, height=34). After the assignment, self.frame
became origin=(x=0, y=0) size=(width=127, height=34).
Why the "origin" value is lost here?