我想将'color'变量'连接'到导入的svg.我想用Stylekit方法改变填充变量的颜色.有没有办法这样做?
我正在尝试使用绘画代码绘制具有不同角半径的圆角.通过绘制两个圆圈和两个圆形,我几乎所有工作都在工作.问题是我无法使其中一个圆形绘制在x偏移圆半径的宽度为"frame.width - circle_radius" - 最终效果是它保持与帧的右边缘对齐.

感觉我应该能够frame.width - largeCornerRadius在表达式编辑器中编写,但PaintCode对象可以在帧引用中编写.
也就是说,我开始感觉我可以手动编写这段代码:-)
我正在尝试使用具有边框和角半径的CoreGraphics(通过PaintCode)在代码中构建UIImage.我发现图像边缘有一个明显更厚的边框.这似乎是一个iOS错误或我完全遗漏的东西.请指教.
码:
CGRect rect = CGRectMake(0, 0, 53, 100);
//// UIGraphics for UIImage context
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
//// Rectangle Drawing
UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius];
[backgroundColor setFill];
[rectanglePath fill];
[borderColor setStroke];
rectanglePath.lineWidth = 1.4;
[rectanglePath stroke];
//// UIBezierPath to Image
CGContextAddPath(context, rectanglePath.CGPath);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsPopContext();
UIGraphicsEndImageContext();
return image;
Run Code Online (Sandbox Code Playgroud)
图片:
这是1的lineWidth和60的宽度,它看起来仍然有点厚:
我有一个通过 PaintCode 绘制的图标。我需要以编程方式在 XCode 中更改他的颜色。
在 PaintCode 上,我为描边颜色设置了一个变量“ChevronColor”。
现在我有:
@IBDesignable
class IconClass: UIView {
override func draw(_ rect: CGRect) {
StyleKit.drawIcon(frame: self.bounds, resizing: .aspectFit)
}
}
Run Code Online (Sandbox Code Playgroud)
但我想添加这种类型,以便能够设置图标的颜色。
@IBInspectable
var ChevronColor : UIColor {
didSet (newColor) {
setNeedsDisplay()
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道怎么办。
导出 StyleKit 文件后,我在 stylekit 文件中排除了此方法,但事实并非如此:
StyleKit.drawIcon(frame: self.bounds, resizing: .aspectFit, chevronColor: self.ChevronColor)
Run Code Online (Sandbox Code Playgroud) 我在PaintCode中创建了一个自定义按钮.PC有很多关于创建图形的文档,但没有使用它们.
我的方法有效,但它有问题,我会去...我走了一个UIButton子类的路径,我把它放在我的故事板中.然后我给它分配了我的自定义按钮类,我们称之为customButton.使用此方法,您可以在IB中连接动作,并且突出显示的状态由touchesBegan和touchesEnded方法一起处理,该变量与切换突出显示的视图的变量串联,但问题是,突出显示的状态永远不会显示在快速触摸上.
customButton.m:
@interface customButton ()
@property BOOL isPressed;
@end
@implementation customButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
-(void) awakeFromNib {
[super awakeFromNib];
_buttonText = @"Post";
}
- (void)drawRect:(CGRect)rect
{
[StyleKit drawCustomButtonWithFrame:rect pressed:_isPressed buttonText:_buttonText];
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
_isPressed = YES;
[self setNeedsDisplay];
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self sendActionsForControlEvents:UIControlEventTouchUpInside];
_isPressed = NO;
[self setNeedsDisplay]; …Run Code Online (Sandbox Code Playgroud) 注意:是的我知道在Android中还有其他方法可以做按钮,但这只是一个展示我的问题的例子(实际按钮远比复杂得多).所以请不要回复为Android中的按钮提供其他解决方案,我正在寻找使用PaintCode的解决方案...
我在iOS中使用PaintCode多年来绘制自定义按钮,它的工作非常出色.我想为Android做同样的事情,并有以下问题:
这在iOS上非常有效,但在Android上,半径是20 像素而不是点,导致半径小到很小(现在使用高分辨率设备).
或者通常我在PaintCode中使用PaintCode生成的draw方法绘制的所有绘图都很小.
它表示生成的绘图代码没有考虑设备的规模(就像在iOS上一样).
看看https://www.paintcodeapp.com/documentation/android节"缩放"PaintCode建议在android中使用密度指标来执行缩放.这确实有效,但是生成的图形模糊,我猜这是因为我们因缩放而绘制的分辨率较低.所以它不是一个可行的解决方案
class Button1 @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : Button(context, attrs, defStyleAttr) {
var frame = RectF()
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
val displayDensity = resources.displayMetrics.density
canvas?.scale(displayDensity, displayDensity)
frame.set(0f,0f,width.toFloat()/displayDensity,height.toFloat()/displayDensity)
StyleKitName.drawButton1(canvas, frame)
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议可以解决吗?这是PaintCode中的错误吗?
我无法使用PaintCode 2修改约束.

选择组或单个形状后,我点击我想要更改的约束但没有任何反应.谁知道如何处理它???
我有一个简单的渐变:2种颜色,1个位置。但这会吐出无法在UIColors上运行的代码:
let gradient = CGGradientCreateWithColors(CGColorSpaceCreateDeviceRGB(), [gradientColor2.CGColor, gradientColor2.blendedColorWithFraction(0.5, ofColor: gradientColor).CGColor, gradientColor.CGColor], [0.14, 0.5, 1])!
Run Code Online (Sandbox Code Playgroud)