By default, AppKit views are not backed by Core Animation layers; layer-backing support has been integrated into AppKit retroactively. But while you never have to worry about this with UIKit, with AppKit there are decisions to make. AppKit differentiates between layer-backed and layer-hosting views, and layer backing can be turned on and off on a per-view-tree basis.
The most straightforward approach to enable layer backing is to set the wantsLayer property to YES on the window’s content view. This will cause all views in the window’s view tree to have their own backing layers, so there’s no need to repeatedly set this property on each individual view. This can be done in code or simply in Interface Builder’s View Effects Inspector.
In contrast to iOS, on the Mac you should treat the backing layers as an implementation detail. This means you should not try to interact with the layers directly, as AppKit owns those layers. For example, on iOS you could simply say: SELECT ALL
But in AppKit, you shouldn’t touch the layer. If you want to interact with the layer in such ways, then you have to go one step further. Overriding NSView’s wantsUpdateLayer method to return YES enables you to change the layer’s properties. If you do this though, AppKit will no longer call the view’s drawRect: method. Instead, updateLayer will be called during the view update cycle, and this is where you can modify the layer.
history history n history -n history | grep xx !n Expand to command with history number "n". !-n Expand to command that was "n" number of commands before the current commandin history. !xxx execute the last commandwhich start with xxx !?xxx? execute the last commandwhich contain "xxx" !! Expand to the last command
- (IBAction)goToCamera{ AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if(authStatus == AVAuthorizationStatusAuthorized){ [self popCamera]; } else if(authStatus == AVAuthorizationStatusNotDetermined) { NSLog(@"%@", @"Camera access not determined. Ask for permission."); [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted){ if(granted) { NSLog(@"Granted access to %@", AVMediaTypeVideo); [self popCamera]; } else { NSLog(@"Not granted access to %@", AVMediaTypeVideo); [self camDenied]; } }]; } else if (authStatus == AVAuthorizationStatusRestricted) { // My own Helper class is used here to pop a dialog in one simple line. [Helper popAlertMessageWithTitle:@"Error" alertText:@"You've been restricted from using the camera on this device. Without camera access this feature won't work. Please contact the device owner so they can give you access."]; } else { [self camDenied]; } }