I've set a 'tintColor' property on an appearance proxy for a UIView subclass class which can draw one of 5 different shapes using CAShapeLayer and UIBezierPath. I am using a class method to return a UIView the required shape:

+(CustomView*)viewForType:(CustomViewType)type
{
    CustomView* iV = [[CustomView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];

    switch (type)
    {
        case CustomViewTypeOne:
    {
        iV.shapeLayer = [CAShapeLayer layerWithPath:[self typeOneBezierPath]
                                              color:[UIColor whiteColor]];
        break;
    }
    ...

    return iV;
}

How can I pass the 'tintColor' property I set on the appearance proxy to this method?

Edit: It may be worth mentioning not all of the returned views are the same, some of them contain one shape layer while others may contain multiple layers and make use of masking.

有帮助吗?

解决方案

Do you need to pass the tint color property to this method? If you set the tint color to the appearance of theCustomView class, you can easily get the tint color back, using

UIColor *tintColor = [[CustomView appearance] tintColor];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top