Comments (9)
after literally months of searching -- you do it like this -- YES this works!
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
{
let verticalPadding: CGFloat = 8
let maskLayer = CALayer()
maskLayer.cornerRadius = 10 //if you want round edges
maskLayer.backgroundColor = UIColor.black.cgColor
maskLayer.frame = CGRect(x: cell.bounds.origin.x, y: cell.bounds.origin.y, width: cell.bounds.width, height: cell.bounds.height).insetBy(dx: 0, dy: verticalPadding/2)
cell.layer.mask = maskLayer
}
from eureka.
It seems to me the easiest way to add padding/margin is changing the contentView.layoutMargins
as is shown below.
Eureka allows you to customize the look a feel of a particular row type by just setting up defaultCellSetup
or/and defaultCellUpdate
properties.
let's say you want to change how TextRow looks like:
EmailRow.defaultCellSetup = { cell, row in
cell.height = { 50 } // increase the height 6 pt
......
cell.layoutMargins = UIEdgeInsetsZero // remove table cell separator margin
cell.contentView.layoutMargins.left = 20 // set up left margin to 20
.... .
cell.contentView.backgroundColor = .clearColor()
cell.backgroundColor = .orangeColor()
....
}
Even though cell
, row
parameters are strongly typed, I could not get Xcode intellisense work on them. Apparently is a Xcode 7.0.1 bug.
Look at this blogpost to know more about how to customize the cells: http://blog.xmartlabs.com/2015/09/29/Introducing-Eureka-iOS-form-library-written-in-pure-Swift/#fully-customizable.
If defaultCellSetup
and defaultCellUpdate
do not fit your needs, you would probably need to create a custom row: https://github.com/xmartlabs/Eureka#how-to-create-custom-rows-and-cells-- . Also take a look at Eureka example project which contains 2 custom row/cells.
from eureka.
@mtnbarreto Thanks Martin! That helps alot!
Is there a way to set similar visual defaults for a Section?
from eureka.
@sureshjoshi Were you ever able to customize the form the way you wanted? I'm having a lot of difficulty with this working.
from eureka.
Hey @bdrelling, no we actually ended up just making a new UI from scratch which matched what we needed. It's unfortunate, as we probably re-did about half the work that was in Eureka.
from eureka.
Was hoping you'd have better news, but unfortunately we're at the same place. Eureka is such a great framework but we really need to be able to change the look to make it more our own.
Thanks for the quick response.
from eureka.
These may be helpful.. http://stackoverflow.com/questions/25770119/ios-8-uitableview-separator-inset-0-not-working, http://stackoverflow.com/questions/10167266/how-to-set-cornerradius-for-only-top-left-and-top-right-corner-of-a-uiview.
I recommend you guys to play with layoutMargins
and separatorInset
properties of cell, cell content view and table view. Also set up table view using Interface Builder by connecting tableView
outlet.
Notice that you may also have to deal with (preservesSuperviewLayoutMargins)[https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instp/UIView/preservesSuperviewLayoutMargins] property depending on your particular use case scenario.
We can add corner radius to section by adding custom section header/footer views and set up relevant view properties to draw the corners. Alternatively we can draw the corner on first and last section row in case we don't need to display any section header/footer.
from eureka.
@Coners, thx for your advice! Is it possible to set only one margin from the left?
from eureka.
Hi there,
I put this and it's working:
$0.cell.layoutMargins = .zero
$0.cell.separatorInset = .zero
$0.cell.preservesSuperviewLayoutMargins = false
$0.cell.contentView.layoutMargins.left = 8.0
Happy coding
from eureka.
Related Issues (20)
- How to set the position and size of the form HOT 2
- What is the difference between cellUpdate and cellSetup? HOT 1
- TimePickerRow is undeletable in MultivaluedSection HOT 2
- The image of the minus button does not disappear in MultivaluedSection for MultivaluedOptions = [.Insert] HOT 2
- App Store Connect Operation Error: The app references non-public selectors HOT 11
- dyld: Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib HOT 2
- Extend cell with another cell
- Section custom header with xib file+class HOT 10
- SegmentedRow crash due to selectedSegmentIndex == -1 HOT 9
- Reordering sections and rows will return the same initial order and not the updated ones HOT 2
- custom Table Inline Row
- SwitchRow Not responding to second time from user interaction HOT 1
- M1 chip Computer + React Native 0.68 + Xcode 14.2 = Compiling Error HOT 1
- Enable BUILD_LIBRARY_FOR_DISTRIBUTION
- Any rule to validate special characters/ numbers in text field in a cell HOT 1
- Food
- How to turn off the capitalization of Section header tiitle? HOT 1
- Bug in iOS 17 Crash app HOT 1
- How to add multivalued .insert options without a multivalued section?
- Index Validation and Safer Collection Handling in Eureka
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 eureka.