UIView subclass with its own XIB [duplicate]

ThomasM, We had similar ideas about encapsulating behavior inside a custom view (say, a slider with companion labels for min/max/current values, with value-changed events also handled by the control internally). In our current best-practice, we would design the ShareView in Interface Builder (ShareView.xib), as described by Eimantas in his answer. We then embed the ShareView … Read more

Make Background of UIView a Gradient Without Sub Classing

You can use +[UIColor colorWithPatternImage:] to produce a patterned background. Example (bring your own CGGradient): // Allocate color space CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); // Allocate bitmap context CGContextRef bitmapContext = CGBitmapContextCreate(NULL, 320, 480, 8, 4 * 320, colorSpace, kCGImageAlphaNoneSkipFirst); //allocate myGradient CGFloat locationList[] = {0.0f, 1.0f}; CGFloat colorList[] = {0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, … Read more

Rotating a view in layoutSubviews

The problem with the code in the question seems to be that the transformations keep getting added to each other. In order to fix this, the solution is to reset the transformations every time, that is, set it to the identity transform. rotationView.transform = CGAffineTransformIdentity Here is a partial implementation that shows the key parts. … Read more