Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone:can';是否控制绘图渐变的宽度?_Iphone_Objective C_Draw_Gradient - Fatal编程技术网

iPhone:can';是否控制绘图渐变的宽度?

iPhone:can';是否控制绘图渐变的宽度?,iphone,objective-c,draw,gradient,Iphone,Objective C,Draw,Gradient,我需要画一个充满渐变的盒子。我正在使用UIView并覆盖-drawRect方法 以下是我的代码(简化): 当前渐变填充填充视图的整个宽度!如何控制正在绘制的渐变填充框的宽度?无需担心。。找到了答案。我需要剪辑我的CGContextRef以匹配我想要的CGRect: CGContextClipToRect(c, currentBounds); CGContextClipToRect(c, currentBounds);

我需要画一个充满渐变的盒子。我正在使用UIView并覆盖-drawRect方法

以下是我的代码(简化):


当前渐变填充填充视图的整个宽度!如何控制正在绘制的渐变填充框的宽度?

无需担心。。找到了答案。我需要剪辑我的CGContextRef以匹配我想要的CGRect:

CGContextClipToRect(c, currentBounds);
CGContextClipToRect(c, currentBounds);