gpt4 book ai didi

iPhone - 扩展 UIImage 以在运行时自定义绘图

转载 作者:行者123 更新时间:2023-12-03 21:03:23 25 4
gpt4 key购买 nike

如何子类化并直接在 UIImage 上绘图?

我尝试扩展它并使用 CoreGraphicsdrawAtPoint:drawInRect: 上绘制,但是 image 是空白的。并且上面2个draw方法都没有被调用。

请不要回答我可以在 UIView 上绘图,因为我需要一个自定义运行时设计的 UIImage

最佳答案

UIImageView文档中明确指出:

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIImageView_Class/Reference/Reference.html

Subclassing Notes Special Considerations

The UIImageView class is optimized to draw its images to the display. UIImageView will not call drawRect: a subclass. If your subclass needs custom drawing code, it is recommended you use UIView as the base class.

因为现在允许您使用 UIView 来代替,所以我只会回答,不可能覆盖 UIImageViewdrawRect:

关于iPhone - 扩展 UIImage 以在运行时自定义绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11361690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com