Instructions integration with tab bar and cell in iOS swift
Problem:
I had integrated Instructions pod in my project.I want to integrate instructions in my project with tab bar with instructions as well as if cell available then show.Otherwise not show with cell instructions.
Solution:
The below code will be used for get the frame for tab bar icons and collectionview header icon focus instructions.
import Instructions
var coachFrames:[CGRect] = []
var coachStrArray:[String] = []
// # MARK: - viewDidAppear
override func viewDidAppear(_ animated: Bool) {
addDemoFrames()
}
// # MARK: - add frames
func addDemoFrames() {
DispatchQueue.main.asyncAfter(
self.coachFrames = []
self.coachStrArray = []
if let topController = UIApplication.
let itemCount = topController.viewControllers.
for i in 0..<itemCount { //tab bar icons
var frme = self.getFrames(item: i, frm: topController.
if i==0 {
frme.origin.y = frme.origin.y-30
frme.size.height = frme.size.height+30
}
self.coachFrames.append(frme)
self.coachStrArray.append(
}
var menuFrame = self.navBar.frame
menuFrame.size = CGSize(width: 50, height: 50)
self.coachFrames.append(
self.coachStrArray.append(
var searchFrame = self.navBar.frame
searchFrame.origin.x = (searchFrame.origin.x+
searchFrame.size = CGSize(width: 50, height: 50)
self.coachFrames.append(
self.coachStrArray.append(searchIconString)
if let frame1 = self.getHeaderFrameSize(index: 0) {
self.coachFrames.append(frame1)
self.coachStrArray.append(mycellstring1)
}
if self.array2.
self.coachFrames.append(frame2)
self.coachStrArray.append(mycellstring2)
}
if self.array3.count>0,
self.coachFrames.append(frame2)
self.coachStrArray.append(mycellstring3)
}
self.coachFrames.append(self.
self.coachMarksController.
}
})
}
func getFrames(item:Int,frm:CGRect) -> CGRect {
var frames = frm
let safeAreaInsets = self.view.safeAreaInsets
let safeAreaHeight = safeAreaInsets.top + safeAreaInsets.bottom - 20
frames.origin.y = frames.origin.y-safeAreaHeight
return frames
}
extension MyVC {
func getHeaderFrameSize(index:Int) -> CGRect? {
guard let layout = CollView.
return nil
}
let indexPath = IndexPath(item: 0, section: index)
let layoutAttributes = layout.
if var frameNew = layoutAttributes?.frame {
frameNew.origin.y = frameNew.origin.y+self. CollView.frame.origin.
frameNew.origin.x = frameNew.origin.x+self. CollView.frame.origin.
frameNew.size = CGSize(width: 50, height: 50)
return frameNew
} else {
return layoutAttributes?.frame
}
}
}
Comments
Post a Comment