Cgrect cgrectinset (cgrect rect, cgfloat dx, cgfloat Dy );
The application of this struct is centered on the original rect. See Dx and Dy for scaling or amplification.
Each rectangle in the image is the above rectangle as the reference rectangle. Therefore, the next rectangle (for example, the yellow rectangle is the next rectangle for the green rectangle) is smaller than the previous rectangle.
The specific small part should be determined by referring to DX and Dy.
CodeAs follows:
View code Cgcontextaddrect (context, currentrect );
Cgcontextdrawpath (context, kcgpathfillstroke );
Cgrect original = cgrectmake ( 100 , 100 , 200 , 200 );
Cgcontextsetfillcolorwithcolor (context, [uicolor redcolor]. cgcolor );
Cgcontextaddrect (context, original );
Cgcontextdrawpath (context, kcgpathfillstroke );
Cgrect firstrect = cgrectinset (original, 10 , 10 );
Cgcontextsetfillcolorwithcolor (context, [uicolor bluecolor]. cgcolor );
Cgcontextaddrect (context, firstrect );
Cgcontextdrawpath (context, kcgpathfillstroke );
Cgrect secondrect = cgrectinset (firstrect, 10 , 10 );
Cgcontextsetfillcolorwithcolor (context, [uicolor greencolor]. cgcolor );
Cgcontextaddrect (context, secondrect );
Cgcontextdrawpath (context, kcgpathfillstroke );
Cgrect thirdrect = cgrectinset (secondrect, 10 , 10 );
Cgcontextsetfillcolorwithcolor (context, [uicolor yellowcolor]. cgcolor );
Cgcontextaddrect (context, thirdrect );
Cgcontextdrawpath (context, kcgpathfillstroke );
Cgrect fourrect = cgrectinset (thirdrect, 10 , 10 );
Cgcontextsetfillcolorwithcolor (context, [uicolor graycolor]. cgcolor );
Cgcontextaddrect (context, fourrect );
If DX or Dy> 0, it is reduced. If DX or Dy <0, it is expanded.