스와이프 제스처 기반 카드 컨트롤 오픈소스 - TinderSimpleSwipeCards
첨부 '10' |
---|
TinderSimpleSwipeCards
This is for maximum customizability and / or learning purposes, not a pod or drop-in solution
The basics of a Tinder-like swipeable cards interface influenced by http://guti.in/articles/creating-tinder-like-animations/
This is meant to be taken and built off of, not as a simple drag and drop solution. New developers are often forced to use dependencies they don't understand and can't customize. This is the opposite. I've fully explained exactly how this works in detailed comments so that you can take it apart and customize it at will. For a pod/drag and drop solution, seehttps://github.com/modocache/MDCSwipeToChoose
Updates, Questions, and Requests
twitter <--- I am a very light twitterer, so I wont spam you
Relevant Article for deciding how to implement swipe cards into your app
https://medium.com/@cwRichardKim/adding-tinder-esque-cards-to-your-iphone-app-4047967303d1
On top of your current View Controllers
Features:
- Swipe cards left or right to call two separate actions
- Have multiple cards on screen depending on the number of items in an array
- Extremely simple, every component is explained
- Very easily customizeable
Customizeability Examples:
action margin (the distance from the middle required for an action to take place)
squeeze ratio (limit, strength)
rotation (strength, limit, angle)
+ More!
in DraggableView.h
- ACTION_MARGIN: distance from center where the action applies. Higher = swipe further in order for the action to be called
- SCALE_STRENGTH: how quickly the card shrinks. Higher = slower shrinking
- SCALE_MAX: upper bar for how much the card shrinks. Higher = shrinks less
- ROTATION_MAX: the maximum rotation allowed in radians. Higher = card can keep rotating longer
- ROTATION_STRENGTH: strength of rotation. Higher = weaker rotation
- ROTATION_ANGLE: Higher = stronger rotation angle
Each component is also explained thoroughly, so it is highly customizeable in many ways
How to use
files
- ViewController.h/m: example view controller (not necessary)
- DraggableViewBackground.h/m: UIView that holds the DraggableView. This can be put ontop of view controllers or you can set it as the main view of your view controller
- DraggableView.h/m: UIView of the draggable cards
- OverlayView.h/m: UIView of the X and √ images
Setup as View Controller (see ViewController.m)
DraggableViewBackground *draggableBackground = [[DraggableViewBackground alloc]initWithFrame:self.view.frame];
[self.view addSubview:draggableBackground];
Setup as UIView ontop of View Controller
CGRect frame = self.view.frame;
frame.origin.y = -self.view.frame.size.height; //optional: if you want the view to drop down
DraggableViewBackground *draggableBackground = [[DraggableViewBackground alloc]initWithFrame:frame];
draggableBackground.alpha = 0; //optional: if you want the view to fade in
[self.view addSubview:draggableBackground];
//optional: animate down and in
[UIView animateWithDuration:0.5 animations:^{
draggableBackground.center = self.view.center;
draggableBackground.alpha = 1;
}];
Presenting Your Data
Loading Data
- edit -(void)loadCards in DraggableViewBackground.m to dictate what information is loaded and how
- "allCards" holds all the cards you want to show, "loadedCards" only shows the first few so that it doesn't load everything at once.
if card data is loaded after initWithFrame, then make sure the data is included in your custom data array (currently "exampleCardLabels") at the index: yourIndex and then write the code:
DraggableView* newCard = [self createDraggableViewWithDataAtIndex:yourIndex]; [allCards addObject:newCard];
whenever you need to.
- I used exampleCardLabels as an example of how to load data, but feel free to change that
Presenting Data in View
- Customize the presentation of your data in -(DraggableView *)createDraggableViewWithDataAtIndex:(NSInteger)index in DraggableViewBackground.m (eg: make certain data appear on labels or photos in custom UIImageViews)
- to access any card directly, use [loadedCards objectAtIndex:yourIndex]; For example, the card that is currently visible is at [loadedCards firstObject];
Areas for Future Improvement / Involvement
- The repo potentially violates the MVC model by having to much controller functionality in a view (DraggableViewBackground)
- Improved naming (while maintaining legacy and / or easy directions for change)
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
216 | iOS | 리뷰 체크앱 - AppReviews | hooni | 2014.03.18 | 228 |
215 | iOS | UIWebView에서 한글 txt 파일 정상적으로 표시 | hooni | 2014.03.18 | 276 |
214 | iOS | 폼형식 입력가능한 ELCTextFieldCell 예제 | hooni | 2014.03.18 | 262 |
213 | iOS | iAd 샘플소스 PortMeAfter | hooni | 2014.03.18 | 217 |
212 | iOS | 끌어 당겼다 놓으면서 리프레쉬하는 소스 | hooni | 2014.03.18 | 241 |
211 | iOS | 팝업뷰 예제 입니다. | hooni | 2014.03.18 | 271 |
210 | iOS | 아이폰 트래커 소스 - iPhone Tracker조회 수 6899 추천 수 0 2011.04.23 00:52:13 | hooni | 2014.03.18 | 371 |
209 | iOS | Evernote API 사용 샘플 예제 | hooni | 2014.03.18 | 283 |
208 | iOS | Sliding Navigation Controller - 트위터앱 처럼 슬라이딩 컨트롤러 구현가능 | hooni | 2014.03.18 | 236 |
207 | iOS | A SpaceManager Game - 앵그리버드와 같은방식의 게임소스 | hooni | 2014.03.18 | 230 |
206 | iOS | TinyWings 같은 게임만들기 -TinySeal | hooni | 2014.03.18 | 287 |
205 | iOS | KnightFight - 기사를 찾아 총을 쏴라! | hooni | 2014.03.18 | 226 |