たまには自分も質問しようと思います。
swiftでFSCalendarを組み込んだアプリを作成しています。
viewの上半分にFSCalendarViewを、下半分にtableviewを配置しております。
FSCalendarViewにはUISwipeGestureRecognizerをつけていて、
上にスワイプするとFSCalendarViewが週間表示に
下にスワイプすると全画面表示になるようにしております。
Viewの大きさ自体は変わって、tableviewもそれに合わせ、調整されるのですが、
FSCalendarViewの中身が動かなくて、困っています。
全画面表示なのに、内容のカレンダーがそのままの位置
週間表示も1行表示になっただけで、微妙に空白が存在したままになっています。
storyboardで最初にviewの高さを設定していて、
その時の表示が固定されていて動かない感じです。
もちろん、コンストレインに@IBOutletをつけて、
大きさの変更および内在viewのresizeのfuncは呼び出しているのですが、
働いてない印象を受けます。
FSCalendarViewに詳しい人、返信いただけると助かります。
Swift
1class ListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, FSCalendarDelegate, FSCalendarDataSource, FSCalendarDelegateAppearance { 2 3 var drawingHeight : CGFloat = 0.0 4 @IBOutlet weak var calendarView: FSCalendar! 5 @IBOutlet weak var calendarViewHeight: NSLayoutConstraint! 6 7 override func viewDidLoad() { 8 let a = self.view.frame.height 9 let b = self.navigationController?.navigationBar.frame.height 10 let c = self.tabBarController?.tabBar.frame.height 11 let d = UIApplication.shared.statusBarFrame.height 12 self.drawingHeight = a - b! - c! - d 13 14 // gesture settings 15 let swipUpGesture:UISwipeGestureRecognizer = UISwipeGestureRecognizer( 16 target: self, 17 action: #selector(ListViewController.swipUp)) 18 swipUpGesture.direction = .up 19 let swipDownGesture:UISwipeGestureRecognizer = UISwipeGestureRecognizer( 20 target: self, 21 action: #selector(ListViewController.swipDown)) 22 swipDownGesture.direction = .down 23 self.calendarView.addGestureRecognizer(swipUpGesture) 24 self.calendarView.addGestureRecognizer(swipDownGesture) 25 } 26 27 // MARK: -- gesture Recognition 28 @objc func swipUp() { 29 print("swiped up") 30 if self.calendarViewHeight.constant == self.drawingHeight { 31 self.calendarViewHeight.constant = self.drawingHeight * 0.5 32 self.view.updateConstraintsIfNeeded() 33 } else if self.calendarViewHeight.constant == self.drawingHeight * 0.5 { 34 self.calendarView.setScope(.week, animated: false) 35 self.calendarViewHeight.constant = self.drawingHeight * 0.25 36 self.view.updateConstraintsIfNeeded() 37 } else { 38 // UIAlert 39 } 40 } 41 42 @objc func swipDown() { 43 print("swiped down") 44 if self.calendarViewHeight.constant == self.drawingHeight * 0.25 { 45 self.calendarView.setScope(.month, animated: false) 46 self.calendarViewHeight.constant = self.drawingHeight * 0.5 47 self.view.updateConstraintsIfNeeded() 48 } else if self.calendarViewHeight.constant == self.drawingHeight * 0.5 { 49 self.calendarViewHeight.constant = self.drawingHeight 50 self.view.updateConstraintsIfNeeded() 51 } else { 52 // 何もないときはできないよ 53 } 54 } 55 56}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/01 16:59
2019/01/01 17:09