Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section Image not showing. #359

Open
minon250 opened this issue Oct 14, 2021 · 1 comment
Open

Section Image not showing. #359

minon250 opened this issue Oct 14, 2021 · 1 comment

Comments

@minon250
Copy link

Xcode Version: 13
Swift 5
HMSegementedControl Version: 1.5.6

Section Images and titles gets assigned but only the titles shows up and the images do not.
` private func setupPageControls() {

	let image = UIImage(named: "indicator-red")!.withRenderingMode(.alwaysOriginal)
	let images = [image, image, image]

	let segmentedControl = HMSegmentedControl(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 44))
	view.addSubview(segmentedControl)
	segmentedControl.autoSetDimension(.height, toSize: 44)
	segmentedControl.autoPinEdge(toSuperviewEdge: .left)
	segmentedControl.autoPinEdge(toSuperviewEdge: .right)
	segmentedControl.autoPinEdge(toSuperviewEdge: .top)

	segmentedControl.sectionImages = images
	segmentedControl.imagePosition = .leftOfText

	if let fmt = self.configSegmentedControlTitleFormatter() {
		segmentedControl.titleFormatter = fmt
	}
	self.segmentedControl = segmentedControl

	let page = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
	page.willMove(toParent: self)
	view.addSubview(page.view)
	addChild(page)
	page.didMove(toParent: self)

	page.view.autoPinEdge(.left, to: .left, of: view)
	page.view.autoPinEdge(.right, to: .right, of: view)
	page.view.autoPinEdge(.top, to: .bottom, of: segmentedControl)
	page.view.autoPinEdge(.bottom, to: .bottom, of: view)

	page.delegate = self
	page.dataSource = self
	self.pageController = page

}`
@minon250 minon250 changed the title Section Image now showing. Section Image not showing. Oct 14, 2021
@iPermanent
Copy link

You need read the api carefully, there is a property called type, enum value should be HMSegmentedControlTypeTextImages, however it's default value is HMSegmentedControlTypeText, and be careful you also need to set the imagePosion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants