Thursday, June 27, 2019

How to create custom Image view in SwiftUI?


Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or
choose File > New > Project.
In the template selector, select iOS as the platform, select the Single View Apptemplate, and then
click Next.

Enter “CustomImage” as the Product Name, select the Use SwiftUI checkbox, and click Next.
Choose a location to save the project on your Mac.

In Canvas on the right click Resume to display the preview. If the canvas is hidden select Editor >
Editor and Canvas to show it.


First we need to add custom image to Assets folder. Drag drop SwiftUi image to mentioned folder.
Image view can be inserted using Image(_:) initializer.  In ContentView replace Text view with Image view and name of Image .
To make image Circular we need to add  a call to clipShape(Circle()) to apply the circular clipping
shape to the image. The Circle type is a shape that you can use as a mask, or as a view by giving the
circle a stroke or fill.
To add a border to our image view, another circle with a black stroke should be created and then add it as
an overlay to give the image a border.
By adding resizeable() property and using frame property we can width , height and alignment of image.


7 comments:

  1. clipping path is the procedure of creating an introduction around a center item while the rest of the photo is being made transparent.
    All you call for to know about the perfect clipping path company see our website.

    ReplyDelete
  2. Digital camera technology has enabled even the most novice photographer to capture images in stunning detail and clarity. The most obvious source for free images is simply using a personal digital camera.Photo Retouching Service

    ReplyDelete
  3. Thanks so much for sharing this awesome info! I am looking forward to see more postsby you! explanation

    ReplyDelete
  4. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. anchor

    ReplyDelete
  5. Updating WordPress on a test site initially is the best approach to do this - similarly as with some other significant changes you make to your site anytime. error establishing a database connection

    ReplyDelete
  6. For California to make the jump from business as usual to accomplishing atmosphere and vitality objectives at the most minimal conceivable cost,excel vba training london

    ReplyDelete
  7. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! applicant tracking software

    ReplyDelete