Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like petert suggested, after seeing the 'related' posts in the side bar I decided to create my own image. I subclassed UIView and added a background image (for the background with rounded edges) and a standard textlabel on init. To create the background image I make a stretchable image using the CG drawing functions.</p> <pre><code> // create background image CGFloat radius = frame.size.height / 2; CGFloat imgSize = (radius*2)+1; // 1 pixel for stretching UIGraphicsBeginImageContext(CGSizeMake(imgSize, imgSize)); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetAlpha(context, 0.5f); CGContextSetLineWidth(context, 0); CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor); CGFloat minx = 0; CGFloat midx = imgSize/2; CGFloat maxx = imgSize; CGFloat miny = 0; CGFloat midy = imgSize/2; CGFloat maxy = imgSize; CGContextMoveToPoint(context, minx, midy); CGContextAddArcToPoint(context, minx, miny, midx, miny, radius); CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius); CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius); CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius); CGContextClosePath(context); CGContextDrawPath(context, kCGPathFillStroke); UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImage *stretchImage = [viewImage stretchableImageWithLeftCapWidth:radius topCapHeight:radius]; UIImageView *stretch = [[UIImageView alloc] initWithImage:stretchImage]; stretch.frame = self.bounds; stretch.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth); [self addSubview:stretch]; [self sendSubviewToBack:stretch]; [stretch release]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload