2017-11-09 24 views
1

私のUIButtonのタップ領域は、iOS 11以降小さくなっています。確認するために、サブビューの背景色をコメントアウトし、ボタン自体に紫色を塗りつぶしました。iOS 11でUIButtonのタップ領域が小さくなった

は、iOS 10.0.3(必要に応じて示したボタン) enter image description here

iOSの11.1(タップ面積が小さくなった) enter image description here

私のコードは次の通りです。

UIImage *ringImage = [UIImage imageNamed:@"ball20r"]; 
UIEdgeInsets insets = UIEdgeInsetsMake(10,10,10,10); //padding 
UIImage *stretchableImage = [ringImage resizableImageWithCapInsets:insets]; 

UIImageView *imageView = [[UIImageView alloc]initWithImage:stretchableImage]; 
// imageView.backgroundColor = backgroundColor; //disabled for testing 
imageView.frame = CGRectMake(0, 0, label.frame.size.width + 16.0, label.frame.size.height + 16.0); 
[imageView addSubview:label]; 


label.translatesAutoresizingMaskIntoConstraints = NO; 
NSDictionary *viewsDictionary = @{@"label":label}; 
NSArray *constraint_H = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(8)-[label]-(8)-|" 
                   options:0 
                   metrics:nil 
                    views:viewsDictionary]; 
NSArray *constraint_V = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(8)-[label]-(8)-|" 
                   options:0 
                   metrics:nil 
                    views:viewsDictionary]; 
[imageView addConstraints:constraint_H]; 
[imageView addConstraints:constraint_V]; 


UIButton *calendarButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[calendarButton addTarget:self action:@selector(chooseACalendarToSave) forControlEvents:UIControlEventTouchUpInside]; 
calendarButton.frame = imageView.frame; 
[calendarButton addSubview:imageView]; 

//added for testing only 
calendarButton.backgroundColor = [UIColor purpleColor]; 

_calendarButton = [[UIBarButtonItem alloc]initWithCustomView:calendarButton]; 

iOSのエリアをiOS 10.0.3以前のようにするにはどうすればよいですか? ご協力いただきありがとうございます。

答えて

0

答えはこちらです。 iOS 11 UIBarButtonItem images not sizing

if (@available(iOS 9, *)) { 
     [cButton.widthAnchor constraintEqualToConstant: standardButtonSize.width].active = YES; 
     [cButton.heightAnchor constraintEqualToConstant: standardButtonSize.height].active = YES; 
} 

できるだけ早く私は、コードの上に挿入として、ボタンが期待どおりに動作し始めました。ありがとうございました。

関連する問題