AV Foundation is an Apple system framework that exists on macOS and iOS, along with watchOS and tvOS. The goal of this tutorial will be to help you build a fully functional iOS app that’s capable of capturing photos and videos using the device’s cameras. We’ll also be following the principles of good object oriented programming and designing a utility class that can be reused and extended in all your projects.
What is AV Foundation?
"AV Foundation is the full featured framework for working with time-based audiovisual media on iOS, macOS, watchOS and tvOS. Using AV Foundation, you can easily play, create, and edit QuickTime movies and MPEG-4 files, play HLS streams, and build powerful media functionality into your apps." – Apple
So, there you have it. AV Foundation is a framework for capturing, processing, and editing audio and video on Apple devices.

Your app should use the prebuilt camera and media control if,
- You prioritize code sharing over customization.
- Camera or media functionality is just a small part of your overall application.
Your app should use a custom camera control if,
- You prioritize customization over code sharing.
- You don’t want to navigate the user to a new view to take a photo.
- The core experience of the app revolves around the camera.
AVFoundation is a namespace that contains classes for high-level recording and playback capabilities for audio and video on iOS.How do you develop in Xamarin Forms ?
Step 1
You have to create CameraPreview which inherits from View and Bindable Property,
- public class CameraPreview: View {
- public static readonly BindableProperty CameraProperty = BindableProperty.Create(propertyName: "Camera", returnType: typeof(CameraOptions), declaringType: typeof(CameraPreview), defaultValue: CameraOptions.Rear);
- public CameraOptions Camera {
- get {
- return (CameraOptions) GetValue(CameraProperty);
- }
- set {
- SetValue(CameraProperty, value);
- }
- }
- }
CameraOptions contains Enum,
- public enum CameraOptions {
- Rear,
- Front
- }
Step 3
Now we're using our own CamaraPreview in Xaml like below
- <Grid
- BackgroundColor="Transparent"
- HorizontalOptions="FillAndExpand"
- RowSpacing="0"
- VerticalOptions="FillAndExpand"
- >
- <Grid.RowDefinitions>
- <RowDefinition Height="*" />
- <RowDefinition Height="250" />
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <local:CameraPreview
- Grid.Row="0"
- Grid.Column="0"
- Camera="Rear"
- HeightRequest="300"
- HorizontalOptions="FillAndExpand"
- VerticalOptions="FillAndExpand"
- WidthRequest="400"
- />
- <frame
- Grid.Row="0"
- Grid.Column="0"
- BackgroundColor="Transparent"
- BorderColor="White"
- HeightRequest="100"
- HorizontalOptions="Center"
- VerticalOptions="Center"
- WidthRequest="200"
- />
- <StackLayout
- Grid.Row="1"
- Grid.Column="0"
- BackgroundColor="Black"
- Orientation="Vertical"
- >
- <label
- FontSize="Title"
- HorizontalOptions="CenterAndExpand"
- Text="Add Card"
- TextColor="White"
- />
- <label
- FontSize="Large"
- HorizontalOptions="CenterAndExpand"
- Text="Position your card in the frame"
- TextColor="White"
- />
- </StackLayout>
- </Grid>
Now the most important part to is to create renderer to write code in the platform part,
- IOS
- CameraPreviewRenderer & UICameraPreview
CameraPreviewRenderer.cs

arunPosted Mar 13, 2022, 3:09 AM
Is there any way to add zoom functionality in it?
Suchitra SinghPosted Aug 9, 2021, 1:33 AM
Help me please! code is not capturing any image. How to capture image from your code.
Kantithat's KanfungPosted Jun 24, 2021, 3:31 AM
Help me please! How to capture image from your project above. : (