How can I create a custom shape that can display an image?


Ashish Tiwari

In a project I have to display contour plots and other images with different shapes . I don't know how to create such a shape, and how to display an image in it. I also have to place this shape in the list view. Please give me advice.

Thanks in advance.

Remembering Tomar Antill

Try something like this:

profileImageview=[[UIImageView alloc]initWithFrame:CGRectMake(2,10,100,80)];
    UIBezierPath *path = [UIBezierPath new];
    [path moveToPoint:(CGPoint){0, 0}];
    [path addLineToPoint:(CGPoint){100, 0}];
    [path addLineToPoint:(CGPoint){70, 80}];
    [path addLineToPoint:(CGPoint){0, 80}];
    [path addLineToPoint:(CGPoint){0, 0}];

     CAShapeLayer *mask = [CAShapeLayer new];
    mask.frame = profileImageview.bounds;
    mask.path = path.CGPath;

    // Mask the imageView's layer with this shape
    profileImageview.layer.mask = mask;

Related


How can I create a shape in android like the image I added?

Aksukumar Maldeh Can anyone tell me how to create a shape that is somewhat rectangular but ends up being a triangle. Jack' I would use the gradient image from the drawable folder. Let's call it background.png. You can also do it with the icons searchicon.png a

How can I create a shape in android like the image I added?

Aksukumar Maldeh Can anyone tell me how to create a shape that is somewhat rectangular but ends up being a triangle. Jack' I would use the gradient image from the drawable folder. Let's call it background.png. You can also do it with the icons searchicon.png a

How can I create such a shape?

Rudy How can I create this with css? thank you for your help. What I have tried: .box { background: purple; padding: 20px; clip-path: polygon( 70% 100%, 100% calc(100% - 3vw), 100% 0, 0 0, 0 calc(100% - 3vw) ); } <div class="box"></

How can I create a custom shape using CSS3 to match this shape?

3g network train I have a graphic detail, but I want to display the shape using CSS. For this, I'm trying to create a css3shape to match my graph (see attached), but I can't get the result. How can I replicate this graphic? My attempt: this is pretty bad: <div

How can I create a custom shape using CSS3 to match this shape?

3g network train I have a graphic detail, but I want to display the shape using CSS. For this, I'm trying to create a css3shape to match my graph (see attached), but I can't get the result. How can I replicate this graphic? My attempt: this is pretty bad: <div

How can I create a custom shape using CSS3 to match this shape?

3g network train I have a graphic detail, but I want to display the shape using CSS. For this, I'm trying to create a css3shape to match my graph (see attached), but I can't get the result. How can I replicate this graphic? My attempt: this is pretty bad: <div

How can I create this shape in SVG?

Rahul Desai Now, I use an ellipse to set the base of the bars to be shaded. : http://jsfiddle.net/rdesai/MjFgK/55/ _ _ How can I change the style so that the base is as shown in the table below? edit The problem can be reduced to creating a shape like this: I

How can I create this shape in SVG?

Rahul Desai Now, I use an ellipse to set the base of my bars to be shaded. : http://jsfiddle.net/rdesai/MjFgK/55/ _ _ How can I change the style so that the base is as shown in the table below? edit The problem can be reduced to creating a shape like this: I c

How can I create this shape in Flutter?

Anas Ressa Please can anyone help me to create this shape in the top right corner of my phone screen: Thanks in advance. Jaime Ortiz You can use the Stack widget and it's child widgets, it has a container with a circle, after which you can push the circle off

How can I create this shape in SVG?

Rahul Desai Now, I use an ellipse to set the base of my bars to be shaded. : http://jsfiddle.net/rdesai/MjFgK/55/ _ _ How can I change the style so that the base is as shown in the table below? edit The problem can be reduced to creating a shape like this: I c

How can I create the custom label shown in the image below?

Elixir of life How to create this type of tab using the tab control Khabib I believe you are looking for the Mutlinline tag. useTabControl.Multiline Property Gets or sets a value indicating whether more than one row of tabs can be displayed.

How can I create the custom label shown in the image below?

Elixir of life How to create this type of tab using the tab control Khabib I believe you are looking for the Mutlinline tag. useTabControl.Multiline Property Gets or sets a value indicating whether more than one row of tabs can be displayed.

How can I create the custom label shown in the image below?

Elixir of life How to create this type of tab using the tab control Khabib I believe you are looking for the Mutlinline tag. useTabControl.Multiline Property Gets or sets a value indicating whether more than one row of tabs can be displayed.

How can I fit the image to the shape of this PNG image in CSS?

Ryan. How can I put an image on this png image but keep the shape? in CSS? I've seen that there are some ways to do this using SVG clip paths, but I'm wondering if there's a faster way to just set it as a background image or something? Thanks and sorry if this

How can I display the image if the list is empty?

Earth I want to display an image or text in Center as if all No Record Foundthe details were pulled from the API . In Native Android, setEmptyView()for this situation, but don't know how to handle it. The nonstop progress dialog is running, but no text is disp

How can I display an image stored in a variable?

username In genius chat there is a imagefield which can be a URL to an image to display. Here is an example message: { _id: 30, createdAt: new Date(), image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Paris_-_Eiffelturm_und_Marsfeld

How can I display an image stored in a variable?

username In genius chat there is a imagefield which can be a URL to an image to display. Here is an example message: { _id: 30, createdAt: new Date(), image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Paris_-_Eiffelturm_und_Marsfeld

How can I display the image if the list is empty?

Earth I want to display an image or text in Center as if all No Record Foundthe details were pulled from the API . In Native Android, setEmptyView()for this situation, but don't know how to handle it. The nonstop progress dialog is running, but no text is disp

How can I display the missile image on top?

Brett Ezra As you can see below, the images of these little missiles are not out of bounds. How to create an offset that respects angle and rotation. I am using linear interpolation to extract the xy coordinates between the two ends of each line. f

How can i display the image array?

Milan I have a react page where data is fetched using an api. Getting all the data successfully, but unable to get the image array. The code I wrote for this is import React, {Component} from 'react'; export default class RoomDetail extends Component{ con

How can I display information on the back of the image?

Mary I'm trying to create an app that lets users place orders from a menu. My problem is when the user hovers over one of the images in the menu, another image should be displayed along with the item's description and price. The id attribute of each image iden

How can I display an image stored in a variable?

username In genius chat there is a imagefield which can be a URL to an image to display. Here is an example message: { _id: 30, createdAt: new Date(), image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Paris_-_Eiffelturm_und_Marsfeld

How can I display an inverted image on the screen?

Sergey Please help to display the reversed image on the screen (the "main" window). import os, sys import tkinter from PIL.ImageTk import PhotoImage, Image main = tkinter.Tk() catalog1 = 'imgs' catalog2 = 'newImgs' file1 = 'n.jpg' ima1 = os.path.join(catalo