Strange gray rect in the upper left corner of HypnosisView


#1

Hi,

somehow I got a strange gray rectangle in the upper left corner of Hypnosis view. It seems not to be something from my drawing code (you can check below). Any idea what else this could be?

Thanks,
Dominik

Here is my HypnosisView.m

[code]//
// HypnosisView.m
// Hypnosister
//
// Created by Dominik on 14.08.12.
// Copyright © 2012 Dominik. All rights reserved.
//

#import “HypnosisView.h”

@implementation HypnosisView

-(void) drawRect:(CGRect)rect
{
// What rectangle am i filling
CGRect bounds = [self bounds];

// Where is its center
CGPoint center;
center.x = bounds.origin.x + bounds.size.width  / 2;
center.y = bounds.origin.y + bounds.size.height / 2;

// what is the max radius?
float maxRadius = hypot(bounds.size.width, bounds.size.height) / 2;

// Get the context being drawed on:
CGContextRef context = UIGraphicsGetCurrentContext();

// All lines will be drawn with a stroke of 10:
CGContextSetLineWidth(context, 10);


// draw circles
bool useGray = true;
for(int currentRadius = maxRadius; currentRadius >0; currentRadius -= 20)
{
    if(useGray)
    {
        [[UIColor lightGrayColor] setStroke];
    }
    else
    {
        [[UIColor orangeColor] setStroke];
    }
    useGray = !useGray;
    CGContextAddArc(context, center.x, center.y, currentRadius, 0.0, M_PI * 2.0, YES);
    CGContextStrokePath(context);
}

// Create a string
NSString *text = @"Du wirst müde...";

UIFont *font = [UIFont boldSystemFontOfSize:28];

// Where am i going to draw it:
CGRect textRect;
textRect.size = [text sizeWithFont:font];
textRect.origin.x = center.x - textRect.size.width  / 2;
textRect.origin.y = center.y - textRect.size.height / 2;
[[UIColor blackColor] setFill];

// Add shadow
CGSize offset = CGSizeMake(3, 2);
CGColorRef color = [[UIColor darkGrayColor] CGColor];
CGContextSetShadowWithColor(context, offset, 2.0, color);


// Draw the text (with its shadow)
[text drawInRect:textRect withFont:font];

}

@end
[/code]


#2

If if were you, I would comment out the for loop to rule out that it is not the culprit.


#3

Ok, so i finally found my mistake: the code completion tricked me when i created HypnosisViewController.h and changed the parent class to UIViewController, well i thought I changed it to UIViewController, but as i just found out, it was changed to UIVideoEditorController that causes the gray rect on the screen:

#import <Foundation/Foundation.h>

@interface HypnosisViewController : UIVideoEditorController

@end

After changing the parent class to UIViewController everything looks good now

:slight_smile: