Christian Sousa
03/25/2020, 6:24 PMprivate fun generateViewWithShadow(): UIView {
var generatedView = UIView().apply {
translatesAutoresizingMaskIntoConstraints = false
heightAnchor.constraintEqualToConstant(60.0).active = true
}
var size = CGSizeMake(20.0, 20.0)
var offsetVal = CGSizeMake(2.0, 2.0)
var layerPath = UIBezierPath.bezierPathWithRoundedRect(rect= generatedView.bounds, byRoundingCorners = UIRectCornerAllCorners, cornerRadii = size ).CGPath
var shadowLayer = CAShapeLayer().apply {
path = layerPath
fillColor = UIColor.whiteColor.CGColor
shadowColor = UIColor.blackColor.CGColor
shadowPath = layerPath
shadowOffset = offsetVal
shadowOpacity = 1.0F
shadowRadius = 5.0
}
generatedView.layer.addSublayer(shadowLayer)
return generatedView
}
Looking at some swift code, I guess that my translation to kotlin is correct, but I still dont get what it should output.. any ideas?ribesg
03/26/2020, 9:07 AMChristian Sousa
03/26/2020, 9:15 AMribesg
03/26/2020, 9:21 AMribesg
03/26/2020, 9:22 AMChristian Sousa
03/26/2020, 9:24 AMUIView.uiView(
cornerRadius = 6.0,
shadowRadius = 6.0
)
But it gives me an unresolved referenceribesg
03/26/2020, 9:25 AMChristian Sousa
03/26/2020, 9:26 AMribesg
03/26/2020, 9:29 AMclass LoginUIView(frame: CValue<CGRect>) : UIView(frame)
ribesg
03/26/2020, 9:30 AMribesg
03/26/2020, 9:30 AMUIView.
in the definition if you want, I just don’t like having general function like that available everywhere, it’s polluting autocompletionChristian Sousa
03/26/2020, 9:35 AMUIView.uiView
returns just a shadowed view? Or does it return the shadowed with the rounded corners?
I’m asking this because you have also the roundCorners
function. Or you just have it to round corners of something other than a UIView?ribesg
03/26/2020, 9:40 AMOr you just have it to round corners of something other than a UIView?Exactly.
roundCorners
also allows to round only some of the corners and not all of them (the technique is different if you want to round all of them or just some)ribesg
03/26/2020, 9:40 AMribesg
03/26/2020, 9:40 AMChristian Sousa
03/26/2020, 9:41 AMChristian Sousa
03/26/2020, 9:42 AMuiView
to a UIStackView
Christian Sousa
03/26/2020, 9:43 AMribesg
03/26/2020, 10:24 AMribesg
03/26/2020, 10:24 AMclearColor
or null
to have a shadowChristian Sousa
03/26/2020, 10:27 AMUIView.uiView
to create the view, after that tried to use:
var generatedView = UIView().apply {
layer.cornerRadius = 6.0
backgroundColor = UIColor.whiteColor
translatesAutoresizingMaskIntoConstraints = false
heightAnchor.constraintEqualToConstant(60.0).active = true
}
var shadowView = View.uiView(cornerRadius = 6.0,shadowRadius = 6.0)
generatedView.addSubview(shadowView)
return generatedView
But that doesn’t work either