No matter what I try I can't get the variations of this to work... What am I not getting?
func anchorType(for string:String) -> NSLayoutAnchor<AnyObject> {
switch string {
case "x":
return NSLayoutXAxisAnchor
case "y":
return NSLayoutYAxisAnchor
default:
return NSLayoutDimension
}
}
There seems to be no way to determine the class of an anchor.. :(
I don't think this is exactly what you're looking for but I think something like this should work:
I'm not too familiar with this area but I would think that the reason you can't return NSLayoutAnchor is because that class is a generic class while it's subclasses are not.