Git Product home page Git Product logo

ckuitools's People

Contributors

genericspecific avatar yurikoles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ckuitools's Issues

How about a CKDrawableView

Just now I wanted to add a border to a UIView where only the top, left, right are drawn (bottom is empty).

I made a custom class that overrides UIView.

Rather than make this small class, how about a CKDrawbleView where you can add it directly as a sub-view to your view like so:

[myView addSubView:[CKDrawableView alloc] initWithBlock:^(CGRect rect){

//do my drawing here;

}];

UITableView tools

I'm not sure if this is generally useful or not, but if you think so please add:

@implementation UITableView (IndexPaths)

  • (NSIndexPath_)nextIndexPathGiven:(NSIndexPath_)indexPath
    {
    NSIndexPath* nextIndexPath = nil;
    if ([self canEvaluateNextOrPreviousIndexPathGiven:indexPath])
    {
    id delegate = self.dataSource;
    NSInteger sections = [delegate numberOfSectionsInTableView:self];
    NSInteger rowsInSection = [delegate tableView:self numberOfRowsInSection:indexPath.section];
    NSInteger nextRow = indexPath.row + 1;

    if (nextRow == rowsInSection && indexPath.section <= (sections - 1))
    {
        nextIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section + 1];
    }
    else
    {
        nextIndexPath = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section];
    }
    

    }
    return nextIndexPath;
    }

  • (NSIndexPath_)previousIndexPathGiven:(NSIndexPath_)indexPath
    {
    NSIndexPath* previousIndexPath = nil;
    if ([self canEvaluateNextOrPreviousIndexPathGiven:indexPath])
    {
    id delegate = self.dataSource;
    NSInteger previousRow = indexPath.row - 1;

    if (previousRow < 0 && indexPath.section > 0)
    {
        NSInteger previousSection = indexPath.section - 1;
        NSInteger lastRowInSection = ([delegate tableView:self numberOfRowsInSection:previousSection]) - 1;
        previousIndexPath = [NSIndexPath indexPathForRow:lastRowInSection inSection:previousSection];
    }
    else
    {
        previousIndexPath = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
    }
    

    }
    return previousIndexPath;
    }

  • (NSIndexPath_)firstIndexPath
    {
    NSIndexPath_ path = nil;
    id delegate = self.dataSource;
    NSInteger sections = [delegate numberOfSectionsInTableView:self];
    if (sections > 0 && ([delegate tableView:self numberOfRowsInSection:0]) > 0)
    {
    path = [NSIndexPath indexPathForRow:0 inSection:0];
    }
    return path;
    }

  • (NSIndexPath_)lastIndexPath
    {
    NSIndexPath_ path = nil;
    id delegate = self.dataSource;
    NSInteger sections = [delegate numberOfSectionsInTableView:self];
    NSInteger rows = [delegate tableView:self numberOfRowsInSection:sections -1];
    if (sections > 0 && rows > 0)
    {
    path = [NSIndexPath indexPathForRow:rows -1 inSection:sections - 1];
    }
    return path;
    }

/* ============================================================ Private Methods ========================================================= */

  • (BOOL)canEvaluateNextOrPreviousIndexPathGiven:(NSIndexPath*)indexPath
    {
    BOOL canEvaluate = YES;
    if (indexPath == nil)
    {
    canEvaluate = NO;
    }
    else if (self.delegate == nil)
    {
    canEvaluate = NO;
    }
    else
    {
    id delegate = self.dataSource;
    NSInteger sections = [delegate numberOfSectionsInTableView:self];
    if (indexPath.section >= sections || indexPath.section < 0)
    {
    canEvaluate = NO;
    }
    }
    return canEvaluate;
    }

@EnD

Add an umbrella header

Add a CKUITools.h header file that imports everything. . . then I don't have to remember the category names.

Breaks UITextView !!!

Steps to reproduce.

  1. Create an empty project.
  2. Add a View Controller
  3. Add a view with only a UITextView. . . confirm that the text view is happy.
  4. Add CKUITools via CocoaPods

UITextView has blank text!!!!!

  1. Add a different library via CocoaPods

UITextView is ok.

Wierd. . .

UIScreen+CKUITools

Add the following method:

This is the content frame, which is either the whole screen, or the whole screen minus the status bar.

  • (CGRect)contentFrame
    {
    CGSize currentSize = [self currentSize];
    if ([UIApplication sharedApplication].statusBarHidden)
    {
    return CGRectMake(0, 0, currentSize.width, currentSize.height);
    }
    else
    {
    CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    return CGRectMake(0, statusBarHeight, currentSize.width, currentSize.height - statusBarHeight);
    }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.