terenceluffy / appstorestylehorizontalscrollview Goto Github PK
View Code? Open in Web Editor NEWApp store style horizontal scroll view
App store style horizontal scroll view
I try to customize my views inside horizontalScrollView, but the item only appear on once, not completely iterate. Look like this :
I used this code :
if indexPath.row == 0 {
horizontalScrollView.uniformItemSize = CGSize(width: 80, height: 60)
horizontalScrollView.setItemsMarginOnce()
for _ in 1...20{
let imageView = UIImageView(frame: CGRect.zero)
imageView.image = UIImage(named: "cetakidcard")
imageView.contentMode = .scaleAspectFill
let viewSome = UIView()
viewSome.backgroundColor = UIColor.black
let produkLabel = UILabel()
produkLabel.text = "Software Antrian"
let produkImage = UIImageView()
produkImage.image = UIImage(named: "cetakidcard")
produkImage.contentMode = .scaleAspectFill
produkImage.snp.makeConstraints { make in
make.height.equalTo(50)
make.width.equalTo(50)
}
viewSome.addSubview(produkImage)
horizontalScrollView.addItem(viewSome)
}
}
Hi can you fix this problem.
Throughout the project there are references to sampleScorllViewInSwift
when it should be SampleScrollViewInSwift
.
Hi,
Interesting component ๐
Here is a template to help you improve your readme: iOS-readme-template
hello, I have a problem using this library , the element appear on the right top of the layer of scoll , but left they appear below , as you can make them appear below the layer rather than over ?? Thank you
plz answer me.
How do you get the section headers that are shown in the gifs? Ie: Available Times or Photos
Hi,
thanks for great plugin, How can convert the direction from LTR to RTL ?
If there are no items in scroll view app crashes when calling removeAllItems
. It's trying to create range 0...-1
. Could you please add check for this case
After I updated the pod to 1.5 and after that i am not able to use two properties miniMarginPxBetweenItems and miniAppearPxOfLastItem. What version I should use, i am currently working on swift 3.0
Please update to the latest Swift 3 syntax
Is there a way to add event listener for the horizontal scroll view?
I would like to detect which item in the horizontal scroll view has been touched.
let horizontalScrollView = ASHorizontalScrollView(frame:CGRect(x: 0, y: 0, width: timesView.frame.size.width, height: 50))
timeButtonsArr.removeAll()
horizontalScrollView.removeAllItems() ->> Not Working
timesView.addSubview(horizontalScrollView)
for _ in 1...3{
let button = UIButton(frame: CGRect.zero)
button.backgroundColor = UIColor.blue
horizontalScrollView.addItem(button)
}
Give me a solution... plz.
Result of call to 'removeAllItems()' is unused
I added the function centerSubviews into ASHorizontalScrollView.swift and in refreshSubviews I added this but elements in the scroll view will still not center.
fileprivate func refreshSubView()
{
self.setItemsMarginOnce();
var itemX = self.leftMarginPx
for item in self.items
{
item.frame = CGRect(x: itemX, y: item.frame.origin.y, width: item.frame.width, height: item.frame.height)
itemX += item.frame.width + self.itemsMargin
}
itemX = itemX - self.itemsMargin + self.leftMarginPx;
self.centerSubviews()
self.contentSize = CGSize(width: itemX, height: self.frame.size.height)
}
Hey, we love this library!
We are having a bit of difficulty right now though. We have a horizontal scrollview in our view controller. When we add test views, simply UIButtons, to the view they add properly and scroll as expected.
When we wired in our function to show the actual UIView content we desire to be displayed, it gets weird. If we provide only a single view to the horizontal scroll view, all displays as expected. If we provide two or more views, then NO views display at all.
We have stepped through and seen our actual views being created and returned, but the HorizontalScrollView is just not displaying 2 or more.
Any ideas on how we can debug this further?
Thanks!
Hello, I have a question need to consult
for _ in 0 ... 10 {
let button = UIButton(frame: CGRectZero)
button.backgroundColor = UIColor.purpleColor()
button.addTarget(self, action: #selector(tapButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
horizontalScrollView.addItem(button)
}
when i touch one button , how to get the button idnex..
๐
Now this situation
[item1_item2_item3______ ]
I want make like this
[_item1_item2_item3]
Thanks!
Hi,
I'm currently making a application and I'm using your amazing ScrollView because it's pretty easy to use. However I still don't understand a couple things. I currently have this piece of code to generate the items:
for rows in 0...20 {
if indexPath.row == rows {
horizontalScrollView.arrangeType = .byNumber
horizontalScrollView.marginSettings_320 = MarginSettings(leftMargin: 1, numberOfItemsPerScreen: 4.25)
horizontalScrollView.marginSettings_480 = MarginSettings(leftMargin: 1, numberOfItemsPerScreen: 5.25)
horizontalScrollView.marginSettings_414 = MarginSettings(leftMargin: 1, numberOfItemsPerScreen: 4.25)
horizontalScrollView.marginSettings_736 = MarginSettings(leftMargin: 1, numberOfItemsPerScreen: 7.375)
horizontalScrollView.uniformItemSize = CGSize(width: 400, height: 280)
horizontalScrollView.setItemsMarginOnce()
for _ in 1...20 {
// ==============
// ==== CARD ====
// ==============
let card = UITableViewCell(frame: CGRect(x: 0, y: 0, width: 800, height: 280))
card.layer.cornerRadius = 5.0
card.layer.borderWidth = 1.0
card.layer.borderColor = UIColor(hex: colors["main"] !).cgColor
// ===============
// ==== IMAGE ====
// ===============
let cardImage = UIImage(named: "header")
let cardImageView = UIImageView(image: cardImage)
cardImageView.frame = CGRect(x: 0, y: 0, width: 400, height: 180)
cardImageView.roundCorners(corners: [.topLeft, .topRight], radius: 5.0)
// =====================
// ==== CARD FOOTER ====
// =====================
let cardFooter = UIView(frame: CGRect(x: 0, y: 180, width: 400, height: 100))
cardFooter.backgroundColor = UIColor.white
cardFooter.roundCorners(corners: [.bottomLeft, .bottomRight], radius: 5.0)
// info button
let btn = UIButton(frame: CGRect(x: 240, y: 60, width: 150, height: 30))
btn.setTitle("More info".uppercased(),
for: UIControlState.normal)
btn.setTitleColor(UIColor(hex: colors["main"] !),
for: UIControlState.normal)
btn.layer.borderWidth = 1.0
btn.layer.borderColor = UIColor(hex: colors["main"] !).cgColor
btn.layer.cornerRadius = 3.0
btn.titleLabel!.font = UIFont.boldSystemFont(ofSize: 12)
btn.addTarget(self, action: #selector(log(button: )),
for: UIControlEvents.touchUpInside)
let label = UILabel(frame: CGRect(x: 10, y: 10, width: 200, height: 30))
label.text = "Job titel"
label.font = UIFont.boldSystemFont(ofSize: 20)
let sublabel = UILabel(frame: CGRect(x: 10, y: 40, width: 200, height: 30))
sublabel.text = "Small description for the job application..."
sublabel.font = UIFont.boldSystemFont(ofSize: 10)
cardFooter.addSubview(label)
cardFooter.addSubview(sublabel)
cardFooter.addSubview(btn)
card.addSubview(cardImageView)
card.addSubview(cardFooter)
horizontalScrollView.addItem(card)
}
}
cell ? .contentView.addSubview(horizontalScrollView)
horizontalScrollView.translatesAutoresizingMaskIntoConstraints = false
cell ? .contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: kCellHeight))
cell ? .contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: cell!.contentView, attribute: NSLayoutAttribute.width, multiplier: 1, constant: 0))
}
What this does is, it generates 20 scrollable rows, with each 20 items inside of it.
They all have the same Image, Title, and Subtitle tho because I provided that in the loop.
How would I go and add a different Image, Title and Subtitle for each one.
For example, how would I set them for the 4th row and 8th item.
A small explanation would be appreciated.
Thanks!
Firstly i add the horizontalScrollView to UIView seen no problem. But Added to table view cell does not show the last items and scroll view width is beyond the container view.
here is my code...
let horizontalScrollView = ASHorizontalScrollView(frame:CGRectMake(0, 30, containerView.frame.size.width , 150))
horizontalScrollView.backgroundColor = UIColor.blueColor() //add color for testing
horizontalScrollView.leftMarginPx = 30
horizontalScrollView.miniMarginPxBetweenItems = 15
horizontalScrollView.miniAppearPxOfLastItem = containerView.frame.size.width-(200+30+50)
horizontalScrollView.uniformItemSize = CGSizeMake(200, 150)
//This must be called after changing any size or margin property of this class to get acurrate margin
horizontalScrollView.setItemsMarginOnce()
for nub in 1...7{
if let addView = NSBundle.mainBundle().loadNibNamed("ScrollViewController", owner: ScrollViewController(), options: nil)[0] as? ScrollView{
addView.titleLable.text = "\(nub)"
horizontalScrollView.addItem(addView)
}
}
containerView.addSubview(horizontalScrollView)
I want to add multiple UIView items with variable sized widths and same sized heights to ASHorizontalScrollView. I briefly looked at the ASHorizontalScrollView code and there were many references to uniform item size. So I wasn't sure if I could have UIViews with variable sized widths. Could you confirm if this is possible?
Thanks in advance.
Hi,
As I can add several UIView , which within each UIView has an image and a text below ?
thanks
`import UIKit
import ASHorizontalScrollView
class ViewController: UIViewController {
@IBOutlet weak var scrollView: ASHorizontalScrollView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
scrollView.removeAllItems()
//Thread 1:EXC_BAD_ACCESS (code = 2, address = 0x11199a9e8)
scrollView.uniformItemSize = CGSize(width: 80, height: 50)
//Thread 1:EXC_BAD_ACCESS (code = 2, address = 0x11199a9e8)
}
}
`
Thread 1:EXC_BAD_ACCESS (code = 2, address = 0x11199a9e8)
what is first settings?
How to use in the ScrollView?
`let horizontalScrollView:ASHorizontalScrollView = ASHorizontalScrollView(frame:CGRect(x: 0, y: Y, width:ScreenWidth, height: 50))
//for iPhone 5s and lower versions in portrait
horizontalScrollView.marginSettings_320 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 5, miniAppearWidthOfLastItem: 20)
//for iPhone 4s and lower versions in landscape
horizontalScrollView.marginSettings_480 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 5, miniAppearWidthOfLastItem: 20)
// for iPhone 6 plus and 6s plus in portrait
horizontalScrollView.marginSettings_414 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 5, miniAppearWidthOfLastItem: 20)
// for iPhone 6 plus and 6s plus in landscape
horizontalScrollView.marginSettings_736 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 10, miniAppearWidthOfLastItem: 30)
//for all other screen sizes that doesn't set here, it would use defaultMarginSettings instead
horizontalScrollView.defaultMarginSettings = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 10, miniAppearWidthOfLastItem: 20)
horizontalScrollView.uniformItemSize = CGSize(width: 80, height: 50)
//this must be called after changing any size or margin property of this class to get acurrate margin
tab1.addSubview(horizontalScrollView)
for _ in 1...20{
let button = UIButton(frame: CGRect.zero)
button.backgroundColor = UIColor.purple
horizontalScrollView.addItem(button)
}
horizontalScrollView.setItemsMarginOnce()
horizontalScrollView.refreshSubView()
scroolview.addSubview(tab1)`
Need smooth work, like natural App Store horizontal scroll
I have a problem, I created a uiview with image , but the minMarginPxBetweenItems can't be less than 0px . If I set minMarginPxBetweenItems = -8.0 ( between 0 and -7 not change nothing), the subviews overlap. How do I set no margin between items?
tnx :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.