如何使用UIBezierPath或其他方法在objective-C中以编程方式创建自定义矩形?

问题描述:

First custom rectangle如何使用UIBezierPath或其他方法在objective-C中以编程方式创建自定义矩形?

Second custom rectangle

如何创建这个定制的UIImageView形状,如矩形1,矩形2?在此先感谢

UIBezierPath *aPath = [UIBezierPath bezierPath]; 
    // Set the starting point of the shape. 
    if (Flag==0) { 
//First rectangle 

     [aPath moveToPoint:CGPointMake(0.0, 0.0)]; 
     // Draw the lines. 

     [aPath addLineToPoint:CGPointMake(375.0, 0.0)]; 

     [aPath addLineToPoint:CGPointMake(367.5, 32.8)]; 

     [aPath addLineToPoint:CGPointMake(7.5, 32.8)]; 

      } else { 
//Second Rectangle 

     [aPath moveToPoint:CGPointMake(7.5, 0.0)]; 

     [aPath addLineToPoint:CGPointMake(367.5, 0.0)]; 

     [aPath addLineToPoint:CGPointMake(375, 32.8)]; 

     [aPath addLineToPoint:CGPointMake(0, 32.8)]; 

    } 

    [aPath closePath]; 

    return aPath;