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
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 [img]https://i.stack.imgur.com/8p78K.png[/img]
my view is made by GUI this is the image of my stack of views , the last view is mainViewContainer [img]https://i.stack.imgur.com/e2Hi5.png[/img]
Каждый раз, когда я создаю экземпляр UIView и добавляю UIBezierPath в качестве маски с помощью функции roundSpecificCorners:withRadius:, представление кажется имеющим меньшие поля с правой стороны и снизу, из-за чего оно не покрывает все...
Я пытаюсь добавить наложение (вид маркера) вместе с моим путем, созданным UibezierPath. Я могу достичь этого с жесткими значениями, сравнивающими x и y графа. Но проблема заключается в том, что это слишком много жестко кодировать, так как ожидаются...
Я хочу переместить UIViewB и сохранить положение всех представлений, как будто ничего не произошло. Я хочу, чтобы viewC вернулся в исходное место до перемещения viewB. Как? Это должно применяться ко всем углам, независимо от того, как вращается...