Почему при первом добавлении UIBezierPath в качестве маски в UIView справа и снизу появляется меньшее поле?IOS

Программируем под IOS
Ответить Пред. темаСлед. тема
Anonymous
 Почему при первом добавлении UIBezierPath в качестве маски в UIView справа и снизу появляется меньшее поле?

Сообщение Anonymous »


Every time I instantiate a UIView and add a UIBezierPath as a mask using the roundSpecificCorners:withRadius: function, the view seems to have a smaller margin on the right side and bottom, causing it not to cover the entire view as expected.

@implementation LoginAccountViewController - (void)viewDidLoad { [super viewDidLoad]; // Initial setup of the view enterEmailView.inputTextField.placeholder = @"Enter Email"; enterPasswordView.inputTextField.placeholder = @"Enter Password"; } - (void)viewWillLayoutSubviews{ // Apply corner rounding on the main view [mainViewContainer roundSpecificCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadius:10.0]; [super viewWillLayoutSubviews]; } - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { __weak typeof(self) weakSelf = self; [coordinator animateAlongsideTransition:^(id context) { // Apply corner rounding when changing orientation UIWindowScene *windowScene = (UIWindowScene *)self.view.window.windowScene; UIInterfaceOrientation orientation = windowScene.interfaceOrientation; if (UIInterfaceOrientationIsLandscape(orientation)) { [weakSelf.mainViewContainer roundSpecificCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadius:10.0]; } else { [weakSelf.mainViewContainer roundSpecificCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadius:10.0]; } } completion:nil]; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; } @end @implementation UIView (CustomLoader) // Other functions here... - (void)roundSpecificCorners:(UIRectCorner)corners withRadius:(CGFloat)radius { // Apply a layer mask with corner rounding CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius, radius)].CGPath; self.layer.mask = maskLayer; // Adjust the autoresizingMask to allow for size changes self.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin; } Why does this behavior occur and how can I fix it so that the view covers the entire screen without any additional margins?

here is an image
Изображение


my view is made by GUI this is the image of my stack of views , the last view is mainViewContainer
Изображение



Источник: https://stackoverflow.com/questions/780 ... ing-a-uibe
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «IOS»