这就是我创建卡片视图的方法。
public void OnAttendLogin(View view) {
sp = getSharedPreferences("attendlogin", MODE_PRIVATE);
String emp_id = sp.getString("emp_id", null);
InTImeWorker inTImeWorker = new InTImeWorker(this);
inTImeWorker.delegate = (AsyncResponse) this;
inTImeWorker.execute(emp_id);
//shared pref for saving In_time in textview
sp = getSharedPreferences("InTime", MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
String in_time_sharedpref = In_time.getText().toString();
editor.putString("in_time_sp", in_time_sharedpref);
editor.apply();
editor.commit();
out_time_button.setEnabled(true);
in_time_button.setEnabled(false);
}
但这不是我想要的,我想要的是一张卡片视图,其中每边的角半径不同,说左上角有5个左下方有10个右上角有20个左下角有半径30个。 我也试过这个,
class Card: UIView {
@IBInspectable var cornerRadius: CGFloat = 3
@IBInspectable var shadowOffsetWidth: Int = 0
@IBInspectable var shadowOffsetHeight: Int = 3
@IBInspectable var shadowColor: UIColor? = UIColor.gray
@IBInspectable var shadowOpacity: Float = 0.5
override func layoutSubviews() {
layer.cornerRadius = cornerRadius
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius)
layer.masksToBounds = false
layer.shadowColor = shadowColor?.cgColor
layer.shadowOffset = CGSize(width: shadowOffsetWidth, height: shadowOffsetHeight);
layer.shadowOpacity = shadowOpacity
layer.shadowPath = shadowPath.cgPath
}
}
但问题出在此问题https://i.stack.imgur.com/JrDKm.png
应该如何
https://i.stack.imgur.com/Pa52p.png 这是没有UIBezierPath的外观 https://i.stack.imgur.com/v6OTc.png