@@ -323,9 +323,10 @@ extension PopMenuViewController {
323
323
fileprivate func calculateContentFittingFrame( ) -> CGRect {
324
324
var height : CGFloat
325
325
326
- if actions. count >= 6 {
326
+ if actions. count >= appearance . popMenuActionCountForScrollable {
327
327
// Make scroll view
328
328
height = CGFloat ( appearance. popMenuActionCountForScrollable) * appearance. popMenuActionHeight
329
+ height -= 20
329
330
} else {
330
331
height = CGFloat ( actions. count) * appearance. popMenuActionHeight
331
332
}
@@ -424,8 +425,6 @@ extension PopMenuViewController {
424
425
425
426
/// Setup actions view.
426
427
fileprivate func configureActionsView( ) {
427
- actionsView. addGestureRecognizer ( panGestureForMenu)
428
-
429
428
actionsView. translatesAutoresizingMaskIntoConstraints = false
430
429
actionsView. axis = . vertical
431
430
actionsView. alignment = . fill
@@ -451,14 +450,45 @@ extension PopMenuViewController {
451
450
actionsView. addArrangedSubview ( action. view)
452
451
}
453
452
454
- contentView. addSubview ( actionsView)
455
-
456
- NSLayoutConstraint . activate ( [
457
- actionsView. leftAnchor. constraint ( equalTo: contentView. leftAnchor) ,
458
- actionsView. rightAnchor. constraint ( equalTo: contentView. rightAnchor) ,
459
- actionsView. topAnchor. constraint ( equalTo: contentView. topAnchor, constant: 4 ) ,
460
- actionsView. bottomAnchor. constraint ( equalTo: contentView. bottomAnchor, constant: - 4 )
461
- ] )
453
+ // Check add scroll view or not
454
+ if actions. count >= ( appearance. popMenuActionCountForScrollable) {
455
+ // Scrollable actions
456
+ let scrollView = UIScrollView ( )
457
+ scrollView. translatesAutoresizingMaskIntoConstraints = false
458
+ scrollView. showsHorizontalScrollIndicator = false
459
+ scrollView. showsVerticalScrollIndicator = !appearance. popMenuScrollIndicatorHidden
460
+ scrollView. indicatorStyle = appearance. popMenuScrollIndicatorStyle
461
+ scrollView. contentSize. height = appearance. popMenuActionHeight * CGFloat( actions. count)
462
+
463
+ scrollView. addSubview ( actionsView)
464
+ contentView. addSubview ( scrollView)
465
+
466
+ NSLayoutConstraint . activate ( [
467
+ scrollView. leftAnchor. constraint ( equalTo: contentView. leftAnchor) ,
468
+ scrollView. topAnchor. constraint ( equalTo: contentView. topAnchor) ,
469
+ scrollView. rightAnchor. constraint ( equalTo: contentView. rightAnchor) ,
470
+ scrollView. bottomAnchor. constraint ( equalTo: contentView. bottomAnchor)
471
+ ] )
472
+
473
+ NSLayoutConstraint . activate ( [
474
+ actionsView. leftAnchor. constraint ( equalTo: contentView. leftAnchor) ,
475
+ actionsView. rightAnchor. constraint ( equalTo: contentView. rightAnchor) ,
476
+ actionsView. topAnchor. constraint ( equalTo: scrollView. topAnchor) ,
477
+ actionsView. heightAnchor. constraint ( equalToConstant: scrollView. contentSize. height)
478
+ ] )
479
+ } else {
480
+ // Not scrollable
481
+ actionsView. addGestureRecognizer ( panGestureForMenu)
482
+
483
+ contentView. addSubview ( actionsView)
484
+
485
+ NSLayoutConstraint . activate ( [
486
+ actionsView. leftAnchor. constraint ( equalTo: contentView. leftAnchor) ,
487
+ actionsView. rightAnchor. constraint ( equalTo: contentView. rightAnchor) ,
488
+ actionsView. topAnchor. constraint ( equalTo: contentView. topAnchor, constant: 4 ) ,
489
+ actionsView. bottomAnchor. constraint ( equalTo: contentView. bottomAnchor, constant: - 4 )
490
+ ] )
491
+ }
462
492
}
463
493
464
494
/// Add separator view for the given action view.
0 commit comments