سؤال

I'm trying to create an overlay on top of a GLKView (effectively an EAGLView). I'm aware of the performance impact, but in my situation that's not a problem, since the scene is paused in the background, it merely needs to remain visible.

I've created a custom UIView called ReaderView whose only custom code is the following:

-(CALayer*)layer {
CATextLayer *textLayer = [[CATextLayer alloc] init];

// Layer settings.
[textLayer setCornerRadius:5.0f];

// Text settings.
[textLayer setFont:CGFontCreateWithFontName((CFStringRef)READING_FONT)];
[textLayer setFontSize:READING_FONT_SIZE];
[textLayer setAlignmentMode:kCAAlignmentJustified];
[textLayer setWrapped:YES];

return textLayer;
}

I've then called the following in a GLKViewController:

-(void)onMyCustomEvent {
if (_readerView==nil) {
    CGRect frame = [[self view] frame];
    frame.size.width *= 0.8f;
    frame.size.height *= 0.8f;
    _readerView=[[ReaderView alloc] initWithFrame:frame];
    [_readerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
}
[_readerView setText:[node content]];
[[self view] addSubview:_readerView];
}

NSLog has proven this method gets called and the reader view gets initialized. However nothing displays on top of the GLKView.

Any idea why this doesn't work?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top