ios - Need to change size and location of CALayer class objects -
I am attempting to copy all the functionality of this example app provided by EpimPM:
< P> The only thing with which I'm having trouble is changing the size and position of a UIView object. The problem is that I am using apple sample code and it just does not make sense to me.Apple offers this sample vice president whom I have called the Media Capture Reviewview. Here is the header file code:
#import & lt; UIKit / UIKit.h & gt; @ Class AVCapture session; @ Interface MediaCaptureViews: UIVU @ Property (Nonomatic) A Wikipedia Session * session; @end
Here it is the main file code:
#import "MediaCapturePreviewView.h" #import & lt; AVFoundation / AVFoundation.h & gt; @implementation MediaCapturePreviewView - (zero) drawRect: (cgartext) {// drawing code} * / + (class) layer class {returns [a vectaptive display layer class]; } - (AVCaptureSession *) session {return [(AVCaptureVideoPreviewLayer *) [self level] session]; } - (zero) set session: (AVCaptureSession *) session {[(AVCaptureVideoPreviewLayer *) [self level] set session: session]; } @ And
Then in my app's central view controller, I have imported the header file of "MediaCapReviewProviewView" which I have shown to you. Last but not least, the main file of my central view controller has an IBOutlet in my interface area that looks like this:
@property (nonatomic, weak) IBOutlet MediaCapturePreviewView * previewView;
The above IBOutlet interface builder is connected to a UIView object that covers the entire iPhone screen.
And then here is a short example of how previewView is used when you tap the "Take a picture" button:
- (IBAction) Snapstick image: sender {sender_sink ([auto-session], ^ {// still update the orientation on the picture output video connection before capturing. [[[Still self-existent] Connection: Video media type: AVMediaTipe video] Set Video Audiation: [[(A Wikipedia The above video previewer *) [[Self preview scene] Layer] Connection] Video Orientation]];
I have tried to add this code immediately after the above method call but this is not help Is doing:
_previewView.frame = CGRectMake (0, 0, self.view.bounds.size.width, self.view .frame.size.height / 2);
I know that you can edit properties for CALayer class objects like frames, boundaries and positions, but I'm stuck now and do not know Yes, again I need to edit these things.
The current UIWUV looks like this when taking a picture:
And I need to see it:
I basically need to take the top 50% of the iPhone's screen.
The video has a default capture ratio that fits for the iPhone Is the screen? If you try to scale it to a different ratio (like half screen), you will get a distorted image or a crop.
In order to achieve what you are trying to do, I think that it will be easier to cover the control of one code with a UIView
, In which you want the control (such as take a photo button) and then crop the full screen image captured for half size like something like this:
CGRect ClipRect = CGRectMake (0, 0, self.view.frame.size.width, self.view.frame.size.height / 2.0); CGImageRef imageRef = CIMMage Crete with iMageInRect ([Image CGImage], ClippedRect); UIImage * newImage = [UIImage imageWithCGImage: imageRef]; CGImageRelease (imageRef);
Comments
Post a Comment