This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ============================================================================================ | |
| // Code | |
| // | |
| // Example showing how to set a View's background to a tiled bitmap. | |
| // assumes: res/drawable/pattern01.png - The bitmap representing an individual tile | |
| public void setViewTiledBackground(View view, Resources resources) { | |
| Bitmap tile = BitmapFactory.decodeResource(resources, R.drawable.pattern02); | |
| BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(resources, tile); | |
| tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int main(String[] args) { | |
| try { Private.testFieldAccess(); } | |
| catch (Throwable e) { e.printStackTrace(); } | |
| } | |
| private static class Private { | |
| private String privateString = null; | |
| public Private(String privateString) { | |
| this.privateString = privateString; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private int determineTitleBarHeight() { | |
| Window window = activity.getWindow(); | |
| Rect windowRect = new Rect(); | |
| window.getDecorView().getWindowVisibleDisplayFrame(windowRect); | |
| return windowRect.top; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git push <remote-name> <branch-name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # show hidden files | |
| defaults write com.apple.finder AppleShowAllFiles TRUE | |
| killall Finder | |
| # hide hidden files | |
| defaults write com.apple.finder AppleShowAllFiles FALSE | |
| killall Finder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // =================================================================================== | |
| // File's Owner needs to implement UITextFieldDelegate protocol in order for the | |
| // keyboard to automatically close when the user hits the Return/Enter key. | |
| // | |
| @interface MyViewController : UIViewController <UITextFieldDelegate> { | |
| IBOutlet UITextField *userInput; | |
| } | |
| @property (nonatomic, retain) UITextField *userInput; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)drawRect:(CGRect)rect | |
| { | |
| CGContextRef context = UIGraphicsGetCurrnetContext(); | |
| CGGradientRef gradient = [self gradient]; | |
| CGPoint startPoint = CGPointMake(CGRectGetMidX(self.bounds), 0.0); | |
| CGPoint endPoint = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMaxY(self.bounds)); | |
| CGContextDrawLinearGradient(context, gradient, startPoint, endPoint); | |
| } | |
| -(CGGradientRef)gradient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(UIBezierPath *)triangleWithPoints:(CGPoint *)points | |
| { | |
| UIBezierPath *path = [UIBezierPath bezierPath]; | |
| [path moveToPoint:points[0]] | |
| [path addLineToPoint:points[1]]; | |
| [path addLineToPoint:points[2]]; | |
| [path closePath]; | |
| return path; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)fillCircleCenteredAt:(CGPoint)center | |
| { | |
| UIBezierPath *path = [UIBezierPath bezierPath]; | |
| [path addArcWithCenter:center | |
| radius:50.0 | |
| startAngle:0.0 | |
| endAngle:2.0 * M_PI | |
| clockwise:NO]; | |
| [path fill]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)drawShadowedText | |
| { | |
| CGContextRef context = UIGraphicsGetCurrentContext(); | |
| CGContextSaveGState(context); | |
| CGFloat shadowHeight = 2.0; | |
| CGContextSetShadowWithColor(context, CGSizeMake(1.0, -shadowHeight), 0.0, [[UIColor orangeColor] CGColor]); | |
| [@"March" drawInRect:monthRect withFont:font]; | |
| CGContextRestoreGState(context); | |
| } |