Comments (6)
For that I would subclass MGLine
and provide a new setup
method which defines the desired row fonts, padding, etc. And instead of using MGTableBoxStyled
I would simply use MGTableBox
or MGBox
as the table container. MGTableBoxStyled
is designed to have rounded corners, so it's not much use in this case.
For Flowies I have an MGLine
subclass called StyledLine
, which has this setup
method:
- (void)setup {
[super setup];
// text style
self.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:18];
self.textColor = UIColor.whiteColor;
// etched borders
self.borderStyle = MGBorderEtchedTop | MGBorderEtchedBottom;
// padding
self.leftPadding = 16;
self.rightPadding = 16;
}
And a convenience line
method to return a line with the default size, like this:
+ (id)line {
return [self boxWithSize:(CGSize){320, 60}];
}
Then I would make the table something like this:
MGBox *table = MGBox.box;
[self.scroller.boxes addObject:table];
StyledLine *line1 = StyledLine.line;
line1.leftItems = (id)@"Some text on the left";
[table.boxes addObject:line1];
StyledLine *line2 = StyledLine.line;
line2.leftItems = (id)@"Some text on the left";
[table.boxes addObject:line2];
[self.scroller layoutWithSpeed:0.3 completion:nil];
from mgboxkit.
Thanks that very helpful.
from mgboxkit.
Hi: This is an unrelated question but I dont want to open a new thread.
I wanted to create a grid hierarchy, as such...
this is my code.. I get error "Assertion failure in +[MGLayoutManager layoutBoxesIn:] NSInternalInconsistencyException', reason: 'Items in the boxes set must conform to MGLayoutBox"
Could you point out where my errors are?
//main box
__weak MGBox *movieGrid = [MGBox boxWithSize:CGSizeMake(_table.frame.size.width, 160.0)];
movieGrid.padding = UIEdgeInsetsMake(10.0, 10.0, 0.0, 10.0);
movieGrid.contentLayoutMode = MGLayoutGridStyle;
//purple box
MGBox *infoBoxGrid = [MGBox boxWithSize:CGSizeMake((movieGrid.size.width - (movieGrid.leftPadding + movieGrid.rightPadding)) * .8, 160.0)];
infoBoxGrid.contentLayoutMode = MGLayoutGridStyle;
//items in purple box
StyledLine *movieInfoBox = [StyledLine lineWithSize:CGSizeMake(infoBoxGrid.size.width, infoBoxGrid.size.height)];
movieInfoBox.leftItems = [NSMutableArray arrayWithObject:thumbImage];
header.rightItems = [NSMutableArray arrayWithObject:nameLabel];
movieInfoBox.backgroundColor = UIColor.redColor;
[infoBoxGrid.boxes addObject:movieInfoBox];
[movieGrid.boxes addObject:infoBoxGrid];
//red box
MGBox *controlBoxGrid = [MGBox boxWithSize:CGSizeMake((movieGrid.size.width - (movieGrid.leftPadding + movieGrid.rightPadding)) * .2, 160.0)];
controlBoxGrid.contentLayoutMode = MGLayoutGridStyle;
//items in red box
UIGlossyButton *socialButton = [[UIGlossyButton alloc] initWithFrame:CGRectMake(0.0, 0.0, (movieGrid.size.width - (movieGrid.leftPadding + movieGrid.rightPadding)) * .2, 80.0)];
//[socialButton setImage:[UIImage imageNamed:@""] forState:<#(UIControlState)#>];
[controlBoxGrid.boxes addObject:socialButton];
[movieGrid.boxes addObject:controlBoxGrid];
movieGrid.onTap = ^() {
VideoPlayerController *videoController = [[VideoPlayerController alloc] init];
videoController.asset = [AVAsset assetWithURL:movieURL];
[self presentViewController:videoController animated:YES completion:nil];
};
[_table.boxes addObject:movieGrid];
from mgboxkit.
You're adding socialButton
to boxes
, but it's not an MGLayoutBox
(eg MGBox
, MGLine
, etc). You can only add MGLayoutBox
objects to boxes
. You should instead add it to subviews
.
from mgboxkit.
Thanks. How can I make my list scroll horizontally?
from mgboxkit.
There's currently no horizontal layout strategy, unless you use a grid layout and resize the container's width to accommodate. Perhaps that would work for you?
from mgboxkit.
Related Issues (20)
- Clickable links ? HOT 2
- MGLine cuts of bottom of 'g' HOT 1
- Ensuring scroll offset is sensible after rotate
- Is it too early to request MGBoxKit for Swift? HOT 11
- Demo apps don't compile anymore HOT 5
- No visible @interface for 'ScrollView' declares the selector 'layout With Speed:completion:' HOT 1
- Code assistance HOT 10
- Subclassing error with cocoapods HOT 13
- Animation quirk when reducing height of a row in a table-like layout HOT 2
- How to programmatically called setContentOffset like UIScrollView? HOT 2
- Deprecated MGTableBox, MGTableBoxStyled and MGLineStyled. HOT 3
- MGBox doesn't set border view. HOT 3
- Examples Please? HOT 6
- Best way to do vertical columns
- 'Block' type is unknown HOT 6
- How can I enable elastic / bounce scrolling when there are only a few boxes in a MGScrollView HOT 3
- Re-ordering rows - can i put an MGScrollView into editing mode? like `moveRowAtIndexPath`? HOT 3
- Box.onLongPress gets called twice HOT 1
- Not auto size when remove box in MGBox
- Unknown type name 'Block' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mgboxkit.