My view is a black rectangle...but it shouldn't be... Here is my method for drawing the view, which is added to my table view as a subview:
- (void)drawRect:(CGRect)rect
{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* color3 = [UIColor colorWithRed: 0.102 green: 0.737 blue: 0.612 alpha: 1];
UIColor* buttonStrokeColor = [UIColor colorWithRed: 0.925 green: 0.941 blue: 0.945 alpha: 0.004];
//// Image Declarations
UIImage* image = [UIImage imageNamed: @"image"];
UIColor* imagePattern = [UIColor colorWithPatternImage: image];
//// Group 2
{
//// AddButton Drawing
UIBezierPath* addButtonPath = [UIBezierPath bezierPathWithRect: CGRectMake(280.0, 3.0, 30, 30)];
[color3 setFill];
[addButtonPath fill];
[buttonStrokeColor setStroke];
addButtonPath.lineWidth = 1;
[addButtonPath stroke];
//// Group
{
//// Rectangle Drawing
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake(280.0, 3.0, 30.0, 30.0)];
CGContextSaveGState(context);
CGContextSetPatternPhase(context, CGSizeMake(86, 33));
[imagePattern setFill];
[rectanglePath fill];
CGContextRestoreGState(context);
[buttonStrokeColor setStroke];
rectanglePath.lineWidth = 1;
[rectanglePath stroke];
}
}
Could there be something in the code that makes the rectangle black? (its a full black box)
Most likely you are drawing outside of the view's own bounds. All drawing must be done based on the view's bounds, not its frame.
This means the origin is always 0, 0. Update your bezier paths based on the view's origin being 0, 0.
You should also setup your drawing code based on the view's size at runtime. Make your code work properly regardless of what size the view is created by outside code.