应用自定义遮罩时,UITextfield的折角

时间:2020-02-24 10:21:31

标签: ios swift xcode uitextfield cashapelayer

我正在尝试创建一个左角四舍五入的文本字段。为此,我使用了以下代码来应用蒙版。现在,将修剪文本字段的角。知道为什么吗?

<mat-select (valueChange)="changeValue($event)">
 <mat-option *ngFor="let catalog of catalogTitles" [value]="catalog.title">{{catalog.title}}</mat-option>
</mat-select>

这是它的外观(请注意左侧的折角)。

enter image description here

2 个答案:

答案 0 :(得分:0)

这适用于较低的radius和height值,例如4。 而且,随着半径/高度值的增加,折角的高度会继续增加

答案 1 :(得分:0)

尝试使用此

textfieldContainerView.layer.cornerRadius = 5
textfieldContainerView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMinXMaxYCorner]

此外,如果您的部署目标为11.0或更高版本,则此方法也可以使用。