RectView不会远离UIWindow

时间:2014-06-29 22:17:26

标签: objective-c

我有以下简单的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    CGRect firstFrame = CGRectMake(300, 300, 150, 259); //CGRect is a struct not a simple object

    ExampleView *view = [[ExampleView alloc] initWithFrame:firstFrame]; //crea la view
    view.backgroundColor = [UIColor redColor]; //colora la view

    [self.window addSubview:view];

    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

我正在研究XCode 5.1.1,但问题是尽管更改了CGRectMake中的值,但显示的红色矩形仍然保持在同一位置。你知道为什么吗?

修改

enter image description here

enter image description here

这是代码

#import "ExampleView.h"

@implementation ExampleView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];

    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end

0 个答案:

没有答案