ios - drawing image in cameraOverlayView -
i'm using code create uiimagepickercontroller custom cameraoverlayview. testing purposes, overlay's supposed circle draw in circleview using uibezierpath. however, circle drawn in circleview not appearing in overlay. overlay supposed subclass of uiview circleview is. can explain why circle not appearing when overlay pops up? initialize circleview in viewdidload , set cameraoverlayview in viewdidappear.
viewcontroller
@property (strong, nonatomic) circleview *overlay; viewdidload
self.overlay = [[circleview alloc] init]; viewdidappear
if ([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) { uiimagepickercontroller *picker = [[uiimagepickercontroller alloc] init]; picker.delegate = self; picker.allowsediting = yes; picker.sourcetype = uiimagepickercontrollersourcetypecamera; picker.showscameracontrols = no; picker.navigationbarhidden = yes; picker.wantsfullscreenlayout = yes; picker.cameraoverlayview = self.overlay; picker.mediatypes = [[nsarray alloc] initwithobjects: (nsstring *) kuttypemovie, nil]; [self presentviewcontroller:picker animated:yes completion:null]; } circleview
- (id)initwithcoder:(nscoder *)adecoder { if (self = [super initwithcoder:adecoder]) { self.shape = [uibezierpath bezierpathwithovalinrect:(cgrectmake(0, 50, 50, 50))]; } return self; } - (void)drawrect:(cgrect)rect{ [[uicolor colorwithred: (114/255.0) green: (5/255.0) blue:(46/255.0) alpha:1] setfill]; [self.shape fill]; }
there 2 problems here:
your circle overlay view has 0 size, because create
initinstead ofinitwithframe:(initfalls on frame of{0,0,0,0}, because have provided no frame information).your circle overlay view important initialization in
initwithcoder:, method never called, since instantiatinginitinstead.self.shapenil , nothing drawn indrawrect:.
Comments
Post a Comment