Skip to content

Instantly share code, notes, and snippets.

@PsychoH13
Created January 11, 2012 15:03
Show Gist options
  • Select an option

  • Save PsychoH13/1595076 to your computer and use it in GitHub Desktop.

Select an option

Save PsychoH13/1595076 to your computer and use it in GitHub Desktop.
- (NSArray *)TS_addRotationFrameViews;
{
UIView *baseView = containerView;
CGRect bounds = [baseView bounds];
CGFloat halfWidth = ceilf(CGRectGetWidth(bounds) / 2.0f);
CGFloat halfHeight = ceilf(CGRectGetHeight(bounds) / 2.0f);
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(bounds),
CGRectGetMinY(bounds) - halfHeight,
CGRectGetWidth(bounds),
halfHeight)];
UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(bounds),
CGRectGetMaxY(bounds),
CGRectGetWidth(bounds),
halfHeight)];
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(bounds) - halfWidth,
CGRectGetMinY(bounds),
halfWidth,
CGRectGetHeight(bounds))];
UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(bounds),
CGRectGetMinY(bounds),
halfWidth,
CGRectGetHeight(bounds))];
[topView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin];
[bottomView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
[leftView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin];
[rightView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin];
[baseView addSubview:topView];
[baseView addSubview:bottomView];
[baseView addSubview:leftView];
[baseView addSubview:rightView];
NSArray *ret = [NSArray arrayWithObjects:(id[]){ topView, bottomView, leftView, rightView } count:4];
[ret setValue:[UIColor blackColor] forKey:@"backgroundColor"];
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment