Add bottom line to view in SwiftUI / Swift / Objective-C / Xamarin

前端 未结 22 2312
自闭症患者
自闭症患者 2020-11-27 09:19

I would like to keep the border at the bottom part only in UITextField. But I don\'t know how we can keep it on the bottom side.

Can you please advise m

22条回答
  •  难免孤独
    2020-11-27 10:04

    Objective C

            [txt.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
            [txt.layer setBorderColor: [[UIColor grayColor] CGColor]];
            [txt.layer setBorderWidth: 0.0];
            [txt.layer setCornerRadius:12.0f];
            [txt.layer setMasksToBounds:NO];
            [txt.layer setShadowRadius:2.0f];
            txt.layer.shadowColor = [[UIColor blackColor] CGColor];
            txt.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
            txt.layer.shadowOpacity = 1.0f;
            txt.layer.shadowRadius = 1.0f;
    

    Swift

            txt.layer.backgroundColor = UIColor.white.cgColor
            txt.layer.borderColor = UIColor.gray.cgColor
            txt.layer.borderWidth = 0.0
            txt.layer.cornerRadius = 5
            txt.layer.masksToBounds = false
            txt.layer.shadowRadius = 2.0
            txt.layer.shadowColor = UIColor.black.cgColor
            txt.layer.shadowOffset = CGSize.init(width: 1.0, height: 1.0)
            txt.layer.shadowOpacity = 1.0
            txt.layer.shadowRadius = 1.0
    

提交回复
热议问题